Professional Documents
Culture Documents
5types of Calculations in Tableau - Tableau
5types of Calculations in Tableau - Tableau
This article explains the types of calculations you can use in Tableau. You'll
learn the difference between each calculation and how they are computed.
There are three main types of calculations you can use to create calculated
fields in Tableau:
Basic expressions
Table calculations
Basic expressions
Basic expressions allow you to transform values or members at the data source
level of detail (a row-level calculation) or at the visualization level of detail (an
aggregate calculation).
For example, consider the following sample table, which contains data on two
fantasy authors and their books. Perhaps you want to create a column with
only the author's last name and a column that displays how many books are in
each series.
https://help.tableau.com/current/pro/desktop/en-us/calculations_calculatedfields_understand_types.htm 1/16
6/14/2021 Types of Calculations in Tableau - Tableau
https://help.tableau.com/current/pro/desktop/en-us/calculations_calculatedfields_understand_types.htm 2/16
6/14/2021 Types of Calculations in Tableau - Tableau
Row-level calculations
To create a column that displays the author's last name for every row in the
data source, you can use the following row-level calculation that splits on a
space:
SPLIT([Author], '', 2 )
The result can be seen below. The new column, titled Author Last Name is
shown on the far right. The colors demonstrate the level of detail the
calculation is performed at. In this case, the calculation is performed at the
row-level of the data source, so each row is colored separately.
https://help.tableau.com/current/pro/desktop/en-us/calculations_calculatedfields_understand_types.htm 3/16
6/14/2021 Types of Calculations in Tableau - Tableau
https://help.tableau.com/current/pro/desktop/en-us/calculations_calculatedfields_understand_types.htm 4/16
6/14/2021 Types of Calculations in Tableau - Tableau
Aggregate calculations
To create a column that displays how many books are in each series, you can
use the following aggregate calculation:
COUNT([Series])
https://help.tableau.com/current/pro/desktop/en-us/calculations_calculatedfields_understand_types.htm 5/16
6/14/2021 Types of Calculations in Tableau - Tableau
The result can be seen below. The new column, titled Number of Books in
Series - at Series level of detail shows how that calculation would be
performed at the Series level of detail in the view. The colors help demonstrate
the level of detail in which the calculation is being performed.
Sevenwaters 6
Sevenwaters
Sevenwaters
Sevenwaters
Sevenwaters
Sevenwaters
https://help.tableau.com/current/pro/desktop/en-us/calculations_calculatedfields_understand_types.htm 6/16
6/14/2021 Types of Calculations in Tableau - Tableau
But if you drag in Book Id, (which is a more granular field), the calculation
updates based on that new granularity since aggregate calculations are
performed at the visualization level of detail.
https://help.tableau.com/current/pro/desktop/en-us/calculations_calculatedfields_understand_types.htm 7/16
6/14/2021 Types of Calculations in Tableau - Tableau
Just like basic expressions , LOD expressions allow you to compute values at
the data source level and the visualization level. However, LOD expressions
give you even more control on the level of granularity you want to compute.
They can be performed at a more granular level (INCLUDE), a less granular
level (EXCLUDE), or an entirely independent level (FIXED).
For example, consider the same sample table as above. If you wanted to
compute when a book series was launched, you might use the following LOD
expression:
The result can be seen below. The new column, titled Series Launched,
displays the minimum year for each series. The colors help demonstrate the
level of detail in which the calculation is being applied.
https://help.tableau.com/current/pro/desktop/en-us/calculations_calculatedfields_understand_types.htm 8/16
6/14/2021 Types of Calculations in Tableau - Tableau
https://help.tableau.com/current/pro/desktop/en-us/calculations_calculatedfields_understand_types.htm 9/16
6/14/2021 Types of Calculations in Tableau - Tableau
In Tableau, the calculation remains at the Series level of detail since it uses the
FIXED function.
https://help.tableau.com/current/pro/desktop/en-us/calculations_calculatedfields_understand_types.htm 10/16
6/14/2021 Types of Calculations in Tableau - Tableau
If you add another field to the view (which adds more granularity) the values
for the calculation are not affected, unlike an aggregate calculation.
Table calculations
Table calculations allow you to transform values at the level of detail of the
visualization only.
For example, consider the same sample table as above. If you wanted to
compute the number of years since the author released their last book, you
might use the following table calculation:
https://help.tableau.com/current/pro/desktop/en-us/calculations_calculatedfields_understand_types.htm 11/16
6/14/2021 Types of Calculations in Tableau - Tableau
The result is shown below. The new column, titled Years Since Previous Book,
displays the number of years between the book released in that row and the
book released in the previous row (on the far right-side of the column) and
demonstrates how the table calculation is being computed (on the left-side of
the column).
The colors help demonstrate how the table calculation is being computed. In
this case, the table calculation is being computed down each pane.
https://help.tableau.com/current/pro/desktop/en-us/calculations_calculatedfields_understand_types.htm 12/16
6/14/2021 Types of Calculations in Tableau - Tableau
https://help.tableau.com/current/pro/desktop/en-us/calculations_calculatedfields_understand_types.htm 13/16
6/14/2021 Types of Calculations in Tableau - Tableau
https://help.tableau.com/current/pro/desktop/en-us/calculations_calculatedfields_understand_types.htm 14/16
6/14/2021 Types of Calculations in Tableau - Tableau
However, if you change the visualization in a way that affects the layout, such
as removing a dimension from the view, the calculation values change.
For example, in the image below, Author is removed from the viz. Since the
table calculation is computed by pane, removing Author changes the
granularity and layout of the viz (instead of two panes there is now only one).
The table calculation therefore calculates the time between 1956 and 1999.
https://help.tableau.com/current/pro/desktop/en-us/calculations_calculatedfields_understand_types.htm 15/16
6/14/2021 Types of Calculations in Tableau - Tableau
See Also
https://help.tableau.com/current/pro/desktop/en-us/calculations_calculatedfields_understand_types.htm 16/16