Tableau is a widely used data visualization and analytics software that allows users to create interactive and visually appealing dashboards, reports, and presentations from their data. With Tableau, users can connect to various data sources, including databases, spreadsheets, cloud services, and web data connectors, to analyze and visualize their data in real-time.

**Table Calculations**

Table calculations in Tableau are dynamic calculations that are performed on the results of a visualization or a subset of data within a visualization. They allow users to perform complex calculations, comparisons, and transformations directly within Tableau's visualizations, enhancing the depth and flexibility of analysis.

Table calculations operate within the context of a visualization, allowing users to perform calculations on aggregated or summarized data displayed in the visualization. They can also be applied to specific subsets of data using filters, groups, or sets.

**Virtual Table**

For any Tableau visualization, there is a virtual table that is determined by the dimensions in the view. This table is not the same as the tables in your data source. Specifically, the virtual table is determined by the dimensions within the “level of detail,” which means the dimensions on any of the following shelves or cards in a Tableau worksheet:

The dimensions that define how to group the calculation (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.

**Table Calculation Types**

**Difference From calculation**

A **Difference From** table calculation computes the difference between the current value and another value in the table for each mark in the visualization.

Here, there are always two values to consider: the current value, and the value from which the difference should be calculated.

To specify from which value the difference should be calculated:

Right-click a measure in the view and select

**Add Table Calculation**.In the Table Calculation dialog box, for Relative to, select one of the following options:

Previous

Next

First

Last

**Percent Difference From Calculation**

A **Percent Difference From** table calculation computes the difference between the current value and another value in the table as a percentage for each mark in the visualization.

**Percent From Calculation**

A **Percent From** table calculation computes a value as a percentage of some other value—typically, as a percentage of the previous value in the table—for each mark in the visualization.

**Percent of Total Calculation**

For each mark in the view, a **Percent of Total** table calculation computes a value as a percentage of all values in the current partition.

**Percentile Calculation**

For each mark in the view, a **Percentile** table calculation computes a percentile rank for each value in a partition.

**Ascending/Descending**

Ascending order ranks values from least to most. Descending order ranks values from most to least.

**Rank Calculation**

For each mark in the view, a Rank table calculation computes a ranking for each value in a partition.

**Running Total Calculation**

A Running Total table calculation aggregates values cumulatively in a partition. It can do this by summing values, averaging values, or replacing all values with either the lowest or highest actual value.

**Moving Calculation**

A Moving Calculation table calculation (sometimes referred to as a *rolling* calculation) determines the value for a mark in the view by performing an aggregation (sum, average, minimum, or maximum) across a specified number of values before and/or after the current value.

A moving calculation is typically used to smooth short-term fluctuations in your data so that you can see long-term trends. For example, with securities data there are so many fluctuations every day that it is hard to see the big picture through all the ups and downs. You can use a moving calculation to define a range of values to summarize using an aggregation of your choice.

**Add Secondary Calculation**

With Running Total and Moving Calculation table calculations, you have the option to transform values twice to obtain the result you want—that is, to add a secondary table calculation on top of the primary table calculation. For example, you could add an initial table calculation to calculate the running total for sales per month within each individual year, and then a secondary calculation to calculate the year-over-year percent difference for each month from one year to the next.

Table calculations update dynamically based on user interactions, such as filtering, sorting, and drilling down into data. This allows users to explore and analyze data interactively while observing the impact of their calculations in real-time.

Table calculations are defined using Tableau's calculation editor, where users can select from a list of predefined functions and configure parameters to tailor the calculation to their specific needs. Users can also create custom table calculations using Tableau's formula language.

While table calculations are powerful tools for data analysis, they can impact performance, especially when applied to large datasets or complex visualizations. Users should consider performance implications and optimize calculations where necessary.

Overall, Tableau table calculations provide users with the flexibility and agility to perform sophisticated analysis directly within their visualizations, empowering them to derive insights and make data-driven decisions effectively.

## 留言