Understanding Tableau Table Calculations: Compute Using Explained
Table Calculation Simulation
This calculator demonstrates how Tableau’s “Compute Using” clause affects table calculations. Enter values for different dimensions and see how the calculation’s scope changes.
Choose the type of table calculation.
Enter the dimensions to compute along, separated by commas. Leave blank for default.
Enter dimensions to restart calculation within, separated by commas.
Calculation Results
Result Value
Formula Explanation:
Key Assumptions:
What is Tableau Table Calculations Compute Using?
Table calculations are a powerful feature in Tableau that allow you to perform computations across the data that makes up your visualization. They operate on the aggregated data that is already present in your view, rather than on the raw, underlying data rows. The crucial aspect of mastering table calculations lies in understanding the “Compute Using” clause. This clause dictates the specific dimensions (fields) within your visualization over which the calculation is performed. Without correctly setting “Compute Using”, your table calculations can yield unexpected or incorrect results, making your analysis unreliable.
Who Should Use “Compute Using”:
- Analysts needing to perform calculations like running totals, moving averages, year-over-year growth, or percent of total directly within their Tableau dashboards.
- Users who want to compare values within different partitions of their data (e.g., sales growth for each product category within each region).
- Anyone looking to add dynamic analytical capabilities to their visualizations without complex data preparation or external tools.
Common Misconceptions:
- Misconception: “Compute Using” is just a setting to make the calculation work.
Reality: It’s the *definition* of the calculation’s scope and direction. - Misconception: Table calculations are the same as Level of Detail (LOD) expressions.
Reality: LODs operate on the data source level, while table calculations operate on the aggregated data in the viz level. - Misconception: Once set, “Compute Using” rarely needs adjustment.
Reality: The optimal “Compute Using” often changes as you add or remove dimensions from your view, or restructure your analysis.
Tableau Table Calculations Compute Using Formula and Mathematical Explanation
Table calculations in Tableau don’t have a single, universal formula like a mortgage calculation. Instead, the “formula” is defined by the calculation type itself (e.g., Running Total, Percent of Total, Difference). The “Compute Using” clause then modifies *how* this formula is applied across the dimensions present in your view.
Let’s break down the core concepts:
- Dimensions in the View: These are the fields used on the Rows, Columns, Color, Size, or Detail shelves. They define the “granularity” of your visualization.
- The Calculation Type: This determines the core operation (summation, average, difference, rank, etc.).
- “Compute Using”: This specifies the dimensions to iterate over. It defines the “direction” or “axis” of the calculation. For example, “Compute Using Region” means the calculation will traverse through each region.
- “Partitioning”: This divides the data into distinct “partitions” or groups. The table calculation restarts its computation independently within each partition. For instance, if you “Compute Using Category” and “Partition by Region”, the running total for Category will reset for each new Region.
Common Calculation Types and Their Logic:
1. Running Total:
Logic: Sums the current value with all preceding values along the specified “Compute Using” dimensions.
Formula Concept: `RunningTotal_n = Value_n + RunningTotal_(n-1)`
Partitioning resets the `RunningTotal_0` to `Value_0` at the start of each partition.
2. Percent of Total:
Logic: Calculates the ratio of the current mark’s value to the total value across the specified “Compute Using” dimensions.
Formula Concept: `PercentOfTotal_n = (Value_n / TotalValueAcrossScope)`
The `TotalValueAcrossScope` is the sum of all values considered within the “Compute Using” scope, often the entire partition if no specific partitioning is set.
3. Difference From Previous:
Logic: Subtracts the value of the previous mark from the current mark’s value, along the specified “Compute Using” dimensions.
Formula Concept: `Difference_n = Value_n – Value_(n-1)`
The first value in a partition or the entire scope has no previous value, so the difference is often NULL or zero.
4. Rank:
Logic: Assigns a rank to each mark based on its value (ascending or descending) along the specified “Compute Using” dimensions.
Formula Concept: `Rank_n = Rank based on ordering of Value_n`
Ties can be handled in various ways (e.g., same rank, average rank).
Variable Explanations and Typical Ranges:
| Variable | Meaning | Unit | Typical Range |
|---|---|---|---|
Value_n |
The measure value for the current mark (e.g., Sales) | Measure Unit (e.g., Currency, Count) | Depends on data (e.g., 0 to Millions) |
RunningTotal_(n-1) |
The cumulative sum up to the previous mark | Measure Unit | Depends on data |
TotalValueAcrossScope |
The sum of all values within the calculation’s scope | Measure Unit | Depends on data |
Rank_n |
The ordinal position of the current mark | Integer | 1 to N (where N is number of marks in scope) |
Dimension_i |
A specific dimension field (e.g., Region, Category) | Categorical | Unique values within the dimension |
PartitionStartValue |
The value of the first mark in a partition | Measure Unit | Depends on data |
Practical Examples (Real-World Use Cases)
Example 1: Running Total of Sales by Category, Restarting for Each Region
Scenario: You have sales data across different regions and product categories. You want to see the cumulative sales as you move through categories *within each region*. This helps understand sales momentum per region.
Tableau Setup:
- Columns Shelf: Category
- Rows Shelf: SUM(Sales)
- Color Shelf: Region
- Calculation: Create a calculated field for “Running Total Sales”:
RUNNING_SUM(SUM([Sales])) - Edit Table Calculation:
- Compute Using: Category
- Restarting every: Region
Calculator Inputs (Illustrative):
- Region: North
- Category: Furniture
- Sales Value: 1500
- Calculation Type: Running Total
- Compute Using: Category
- Partitioning: Region
Simulated Output:
- Main Result (Running Total Sales for North, Furniture): 1500
- Intermediate Values:
- Total Sales (for the current partition scope): ~ Sum of all sales for ‘North’ across all categories
- Total Records (in scope): ~ Number of categories in ‘North’
- Current Record Index: 1 (assuming Furniture is the first category in North)
- Formula Explanation: Running Total sums the current value (1500) with preceding values within the ‘North’ partition.
- Key Assumptions: Calculation is performed over ‘Category’ and restarts for each ‘Region’.
Interpretation: The running total shows how sales accumulate as you analyze each category sequentially within the ‘North’ region. If the next category in ‘North’ had sales of 2000, its running total would be 3500 (1500 + 2000).
Example 2: Percent of Total Sales by Region, Across All Regions
Scenario: You want to understand the contribution of each region’s sales to the overall company sales. This helps identify top-performing regions.
Tableau Setup:
- Rows Shelf: Region
- Columns Shelf: SUM(Sales)
- Calculation: Create a calculated field for “Percent of Total Sales”:
SUM([Sales]) / TOTAL(SUM([Sales])) - Edit Table Calculation:
- Compute Using: Region
- Addressing: Region (Default is fine here if Region is the only dimension for addressing)
Calculator Inputs (Illustrative):
- Region: West
- Category: (Not used in this simple setup)
- Sales Value: 50000
- Calculation Type: Percent of Total
- Compute Using: Region
- Partitioning: (Blank)
Simulated Output:
- Main Result (Percent of Total for West): 0.25 (or 25%)
- Intermediate Values:
- Total Sales: 200000 (assuming total sales across all regions is 200,000)
- Total Records: 4 (assuming 4 regions)
- Current Record Index: Varies based on order, but calculation is % of total.
- Formula Explanation: Percent of Total divides the current region’s sales (50,000) by the total sales across all regions (200,000).
- Key Assumptions: Calculation is performed across ‘Region’, with no partitioning.
Interpretation: A result of 0.25 means the ‘West’ region contributes 25% of the total sales. This provides a clear view of relative performance.
How to Use This Tableau Table Calculations Calculator
This calculator helps visualize the impact of “Compute Using” and “Partitioning” on common table calculations. Follow these steps:
- Enter Baseline Data: Input a representative Region, Category, and Sales Value. These represent a single mark in a hypothetical Tableau view.
- Select Calculation Type: Choose the type of table calculation you want to simulate (Running Total, Percent of Total, Difference From Previous, Rank).
- Define “Compute Using”: In the “Compute Using” field, enter the dimensions (like ‘Region’, ‘Category’, ‘Date’, etc.) that your calculation should iterate over. Separate multiple dimensions with commas. This defines the “direction” of the calculation.
- Define “Partitioning”: In the “Partitioning” field, enter dimensions by which the calculation should restart. Separate multiple dimensions with commas. This divides your view into independent segments for the calculation.
- Click “Calculate”: The calculator will process the inputs based on the selected type and the specified “Compute Using” and “Partitioning”.
How to Read Results:
- Main Result: This is the output of the table calculation for the specific scenario you’ve set up. The label clarifies what it represents.
- Intermediate Values: These provide context:
- Total Sales: Represents the aggregate measure within the scope defined by “Compute Using” and “Partitioning”. For “Percent of Total”, this is the denominator. For “Running Total”, it’s the final value of the running total within that scope.
- Total Records: The number of marks (data points) considered within the calculation’s scope.
- Current Record Index: Indicates the position of the current mark within the sequence defined by “Compute Using”.
- Formula Explanation: A plain-language description of the calculation logic applied.
- Key Assumptions: Reiterates the “Compute Using” and “Partitioning” settings that influenced the result.
Decision-Making Guidance:
Use the results to:
- Verify your understanding of how “Compute Using” and “Partitioning” interact.
- Predict how a table calculation will behave in a complex Tableau view.
- Troubleshoot unexpected results in your dashboards.
- Experiment with different calculation scopes without needing direct access to Tableau.
Remember, the actual values in Tableau will depend on the aggregated measures in your specific view. This calculator focuses on the *logic* driven by the “Compute Using” settings.
Key Factors That Affect Tableau Table Calculations Results
Several factors influence the outcome of table calculations in Tableau, beyond just the calculation type. Understanding these is crucial for accurate analysis:
- Dimensions in the View: The fields placed on the Rows, Columns, Color, Detail, Size, and other shelves directly define the marks and the dimensions available for “Compute Using” and “Partitioning”. Adding or removing a dimension can drastically change the calculation’s scope.
- “Compute Using” Setting: This is the most direct influencer. Choosing ‘Table (Across)’, ‘Table (Down)’, ‘Pane (Across)’, ‘Pane (Down)’, or specific dimensions dictates the direction and set of data points the calculation traverses.
- “Restarting Every” (Partitioning): This determines where the calculation resets. If you want to analyze trends within each year, you’d “Compute Using” month and “Restart Every” year. This creates independent calculations for each partition.
- Aggregation of Measures: Table calculations operate on the aggregated measures in the view (e.g., SUM(Sales), AVG(Profit)). Ensure the aggregation is appropriate for your analysis before applying the table calculation.
- Order of Operations: Tableau has a specific order of operations. Filters (extract, context, dimension, measure, final) and FIXED LODs are applied before table calculations. Understanding this hierarchy prevents surprises.
- Data Granularity: The level of detail in your data source and how it’s represented in the view affects the individual marks the calculation operates on. A running total will behave differently if calculated over daily sales versus monthly sales.
- Data Volume and Performance: While not affecting the *result’s logic*, large datasets can impact the performance of complex table calculations. Efficiently defining “Compute Using” and “Partitioning” is key.
- Measure Names/Measure Values: When using Measure Names/Values to display multiple measures, table calculations can become more complex as they operate across these pseudo-dimensions.
Frequently Asked Questions (FAQ)
A: “Compute Using” defines the dimensions the calculation moves across (the direction). “Partitioning” divides the data into independent groups, and the calculation restarts within each group. Think of “Compute Using” as the path and “Partitioning” as the stops where the path resets.
A: Yes, table calculations can operate on dimensions as well, for example, to rank customers by name. However, the most common use is with aggregated measures.
A: It calculates the percentage relative to the sum of all values within the scope defined by “Compute Using” and “Partitioning”. If you “Compute Using Category” and “Partition by Region”, it’s the category’s sales as a % of total sales *for that specific region*.
A: Double-check your “Compute Using” and “Restarting every” settings. Ensure they align with the dimensions you intend to iterate over and partition by. Also, verify the underlying aggregation (SUM, AVG, etc.).
A: “Table (Total)” typically refers to calculating across the entire table (all marks in the visualization), ignoring any specific dimensions unless used for partitioning. It’s often used for overall percentages or totals.
A: LOD expressions (FIXED, INCLUDE, EXCLUDE) are calculated *before* view-level aggregation and filters (except context filters). Table calculations are performed *after* view-level aggregation and operate on the marks in the visualization.
A: Yes, but be mindful of the filter’s type. Dimension filters applied *after* table calculations will affect the results. Context filters and extract filters are applied *before* table calculations, meaning they define the data set the table calculation operates on.
A: You can drag the calculated field containing the table calculation onto the Data pane, then drag it to the new view. Alternatively, right-click the pill in the view, select ‘Edit Table Calculation’, and note the settings, then re-apply them to the same calculation in the new view or create a new one.
Visualizing Table Calculation Behavior
To better understand how different “Compute Using” and “Partitioning” settings impact your data, visual representations are key. Below is a chart showing sales across categories, demonstrating a running total calculation.
Running Total of Sales by Category (Illustrative)
In this chart, you can observe how the ‘Running Total’ line progresses. If “Partitioning” were applied (e.g., by Region), you would see the running total line reset for each new region, illustrating independent calculation scopes.
Structured Data Example
Here’s a sample of how data might be structured and calculated in Tableau, demonstrating a running total calculation across categories within a specific region.
| Region | Category | Sales | Running Total Sales (Compute Using: Category, Restarting Every: Region) | Percent of Total Sales (Compute Using: Category, Restarting Every: Region) |
|---|---|---|---|---|
| North | Furniture | 1500 | 1500 | 1500 / 6000 = 25.0% |
| North | Office Supplies | 2500 | 4000 | 2500 / 6000 = 41.7% |
| North | Technology | 2000 | 6000 | 2000 / 6000 = 33.3% |
| South | Furniture | 1200 | 1200 | 1200 / 5000 = 24.0% |
| South | Office Supplies | 2300 | 3500 | 2300 / 5000 = 46.0% |
| South | Technology | 1500 | 5000 | 1500 / 5000 = 30.0% |
Related Tools and Internal Resources
-
Tableau Table Calculation Simulator
Interactive tool to test “Compute Using” scenarios.
-
Understanding Tableau Level of Detail (LOD) Expressions
Learn the differences and use cases for LODs vs. Table Calculations.
-
Advanced Tableau Dashboard Design Tips
Best practices for creating effective and interactive Tableau dashboards.
-
Data Visualization Best Practices Guide
General principles for creating clear and impactful data visualizations.
-
Optimizing Tableau Performance
Tips and techniques to speed up your Tableau workbooks.
-
Advanced SQL Techniques for Data Analysis
Explore SQL concepts relevant to preparing data for BI tools like Tableau.