﻿ Table Calculations: Addressing and Partitioning
Yes No
Applies to: Tableau Desktop, Tableau Online, Tableau Public, Tableau Server

# Table Calculations: Addressing and Partitioning

If you are configuring table calculations using specific dimensions, then you should become familiar with the concepts of addressing and partitioning.

## Background: How Level of Detail Affects the Direction and Scope of Your Calculations

Your view contains marks; these marks are typically aggregated. This means that an individual mark collects data not from a single row in your data source, but from all rows that have the same values for the dimensions in your view.

See Aggregating Data for more on aggregation in Tableau.

The number of marks in your view is determined by the view’s level of detail. Dimensions located on any of the shelves or cards highlighted in the following image contribute to the level of detail:

So if your view has State and Segment on Columns, and Region on Rows, then a single mark represents all rows in your data source that share the same value for these three dimensions. For example, one mark would aggregate individual values for rows where the value of State is Indiana, the value of Segment is Consumer, and the value of Region is Central. The measure that Tableau is aggregating—it might be Profit, Sales, or any other measure in the data source—is for you to decide, as is the aggregation itself—it might be Sum, Average or another aggregation.

When you add a table calculation, you must use all dimensions in the level of detail either for partitioning (scoping) or for addressing (direction):

• The dimensions that define how to group the calculation, that is, define the scope of data it is performed on, are called partitioning fields. The table calculation is performed separately within each partition.

• The remaining dimensions, upon which the table calculation is performed, are called addressing fields, and determine the direction of the calculation.

Partitioning fields break the view up into multiple sub-views (or sub-tables), and then the table calculation is applied to the marks within each such partition. The direction in which the calculation moves (for example, in calculating a running sum, or computing the difference between values) is determined by the addressing fields. So when you order the fields in the Specific Dimensions section of the Table Calculation dialog box from top to bottom, you are specifying the direction in which the calculation moves through the various marks in the partition.

When you add a table calculation using the Compute Using options, Tableau identifies some dimensions as addressing and others as partitioning automatically, as a result of your selections. But when you use Specific Dimensions, then it’s up to you to determine which dimensions are for addressing and which for partitioning.

The following example demonstrates how experimenting with the options in the Table Calculations dialog box can help you understand how your calculation is working.

## Example - Addressing and Partitioning

In this example, using the Sample – Superstore data source provided with Tableau Desktop, create the following simple view:

1. Drag Order Date and Segment to Columns.

2. Drag State to Rows.

3. Drag Sales to Text.

This gives you a basic view:

4. Click SUM(Sales) on the Marks card and then select Add table calculation from the context menu.

This opens the Table Calculation dialog box.

Note the yellow highlighting running across the top row of the view. Highlighting shows you exactly how the current Compute Using option partitions the view.

5. Set Calculation Type to Running Total.

6. Click Specific Dimensions, the last item in the Compute Using list.

The list box below the Compute Using list, which lists all the dimensions in the view’s level of detail, is now available for edit:

Any field with a check mark is an addressing field. Year of Order Date and Segment are checked, so this leaves State as the only partitioning field. This configuration matches Table (Across), which was the Compute Using value that was selected when you clicked Specific Dimensions.

Note: You can select any of the Compute Using options and then click Specific Dimensions to see how your selected option translates in terms of specific dimensions.

Year of Order Date and Segment are both on Columns in the view, so these dimensions define the columns in the view. Notice that the values running from left to right in the view are ascending—the running total increases across the entire width of the view.

But when you get to the second row (Arizona) you enter a new partition, so the calculation restarts.

To gain insight, try changing things up in the list of specific dimensions.

7. Clear the check mark from Year of Order Date.

Year of Order Date is now a partition field, leaving only Segment for addressing. Year of Order Date and State are both now partitioning fields, which means the partitions are more plentiful—and smaller, because you are using two fields to partition (think “divide up”) the view. There are only three marks per partition now, so as you continue moving left-to-right across the view, you enter a new partition with the fourth value, and the calculation restarts.

By default, marks are highlighted in the first partition in the view. The first headers for these fields are also highlighted—in the current case, 2011 and Alabama.

8. Reselect Year of Order Date and then drag Segment to the top of the list—above Year of Order Date. Highlighting shows that the partition is the same as in the default view, stretching left to right across the entire width of the view. This makes sense because the same two fields— Segment and Year of Order Date—are used for addressing.

But notice that the values are not the same as in the previous view:

Because you reversed the order in which the fields are listed for Specific Dimensions, Tableau computes the running total using values for Segment first and then Year of Order Date. The arrows in the image show the order in which Tableau is computing the running sum. The logic of the calculation is now somewhat at odds with the visual alignment of the view, but that is what can happen when you configure a table calculation using Specific Dimensions.