Tableau is a popular visualization tool. It can connect to any database, create visualizations, and share them within the organization. It empowers businesses to make most of their data by providing deep insights. The ease of use and great visualization capabilities attained it the possibility to get easily adoptable by many companies. Tableau provides a lot of features, in which one of them is calculations. In this post, we will explain about calculations in Tableau. You can get to know how to use calculations in your visualizations. We will also let you know the tips and tricks that might come in handy while creating calculations. If you are new to Tableau, then you are at the right place. Let us get started.
Tableau comes with predefined calculations. Calculations are nothing but applying transformations on values. They are useful in views for creating a total, difference, average, percent difference, percent of the total, etc. It allows users to create a calculated field based on the data source. When your dataset does not provide the information that you need, you can create calculated fields by applying calculations. The calculated field can be used to create visualizations. You can use calculations when you want to segment data, filter through results, converting a data type of a field, etc.
Users can create calculated fields in Tableau using three main types of calculations.
It is useful to transform values at the data source level of detail, i.e., row-level calculation or at the visualization level of detail, i.e., aggregate calculation. The basic calculations scale very well. These are mostly used on the underlying data source.
The LOD expressions are also useful to transform values at the data source level and the visualization level. The LOD expressions are dependent on database performance since they are expressed as nested SELECT. Unlike basic expressions, the LOD expressions provide more control on the level of granularity. The granularity levels can be,
A more granular level (INCLUDE)
A less granular level (EXCLUDE)
An independent level (FIXED)
The table calculations only allow data transformations at the level of detail of the visualization. These calculations are performed on the query result set. Users can apply this calculation only on the virtual table that has numbers of the view. Table calculations are useful for rankings, running totals, and showing the percent of the total. If you want to reduce the performance issue, aggregate the data first, and then perform the calculation on it.
Tableau also provides Ad-hoc calculations that can be used to create and update as you work on a field in a view. They are also known as type-in or in-line calculations. They are supported on Rows, Columns, Marks, and Measure Values shelves. If there are any errors in ad-hoc calculations, they are underlined in red. When you are editing an ad-hoc calculation, you can only see the current line. These calculations won't be named by default but will be saved when you close the workbook. When you save an ad-hoc calculation, it will work as same as the calculations that are created in the calculation editor.
The calculations in Tableau have four basic components or building blocks.
Functions - Pre-defined statements are used to transform values or members in a field.
Fields - Columns or dimensions of a data source.
Operators - Symbols that represent an operation.
Literal expressions - Constant values that can be represented as is.
Calculations might also contain,
Parameters - Variables that can be used in calculations and later replaced with constant values.
Comments - A text about a calculation or a part of the calculation, which should not be included in the calculation.
Tableau offers many functions that can be used in calculations. Here are some of the table calculation functions that are available.
Creating a calculated field
Once you choose a calculation, you have to create a calculated field. Open Tableau, select 'Analysis', and click on 'Create Calculated Field'. You will get a calculation editor where you can create your calculation. Give a name for your calculation, enter the formula, and click on 'OK'. You can observe the newly calculated field being added to the 'Measures' section in the Data pane. The calculated field stands out from the rest as it contains a '=' sign next to the data type icon. This calculated field can then be used in creating visualizations.
Here are some tips and tricks that can help you while working with calculations. These will help you in creating effective calculations.
The type of calculation that you have to use for your data analysis typically depends on your data, the granularity of the visualization, and the output that you want to get. Ranking, recursion, moving calculations, inter-row calculations can only be performed with table calculations. So, analyze your dataset and your end goal before choosing a calculation type. Tableau also provides a parameter control through which users can determine how a calculation has to perform. Since you are familiar with calculations now, try them out in your visualizations in Tableau.
Batch starts on 31st Jul 2021, Weekend batch
Batch starts on 4th Aug 2021, Weekday batch
Batch starts on 8th Aug 2021, Weekend batch