Working with scope and direction

In order to see how scope and direction work together, let's work through a few examples. We'll start by creating our own custom Table Calculations. Create a new calculated field named Index with the code Index().

Index() is a Table Calculation function that starts with the value of 1 and increments by one as it moves along a given direction and within a given scope. There are many practical uses for Index, but we'll use it here because it is easy to see how it is moving for a given scope and direction.

Create the table as shown previously with YEAR(Order Date) and QUARTER(Order Date) on Rows and Region and Department on Columns. Instead of placing Sales in the view, add the newly created Index field to the Text shelf. Then experiment, using the drop-down menu on the Index field and select Compute Using to cycle through various scope and direction combinations. In the following examples, we've only kept the East and West regions and 2 years:

  • Table (across): This is Tableau's default when there are columns in the table. Notice in the following how Index increments across the entire table:

  • Table (down): When using table (down), Index increments down the entire table:

  • Table (across then down): This increments Index across the table, then steps down, continues to increment across, and repeats for the entire table:

  • Pane (across): This defines a boundary for Index and causes Index to increment across until it reaches the pane boundary, at which point the indexing restarts:

  • Pane (down): This defines a boundary for Index and causes Index to increment down until it reaches the pane boundary, at which point the indexing restarts:

  • Pane (across then down): This allows Index to increment across the pane and continue by stepping down. The pane defines the boundary here:

You may use scope and direction with any Table Calculation. Consider how a running total or percentage difference would be calculated using the same movement and boundaries shown here. Keep experimenting with different options until you feel comfortable with how scope and direction work.

Scope and direction operate relative to the table, so you can rearrange fields, and the calculation will continue to work in the same scope and direction. For example, you could swap Year of Order Date with Department and still see Index calculated according to the scope and direction you defined.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.22.74.160