[Part II] Tableau Features— Filters, Parameters, Actions & Calculations
Tableau is a leading data visualization tool used for data analysis and business intelligence.
In the first part of this article, I covered concepts of relationships and data blending as well as multiple features to build dashboards with Tableau. In this second part of the series about Tableau, you will learn Filters, Parameters, Actions & Calculations.
Filters
Filters enable developers to do data cleaning and role based security. And by doing the right filtering at the source level you can gain performance.
The order of execution of these filters in Tableau is:
Extract Filter > Data Source Filter > Context Filter > Dimension Filter > Measure Filter > Table Calculation Filter
Data Source Filter
If you want to hide sensitive data use the Data Source Filter.
Context & Dimension Filter
Context filters and Dimension filters change the structure of the worksheet data table by eliminating rows or columns, filtering by condition, etc. But they are local, if we want to make the filter applied to more worksheets we can configure that in the “Apply to Worksheets”
Measure Filter
Measure filter acts on continuous values so it enables filters in original values or aggregates values e.g. Standard deviation, AVG, SUM, etc.
Parameters
Parameters are variables from the user input that are useful for KPIs.
To make the user interact with the dashboard by dynamically choosing a parameter e.g. the Top N customers, you can add it to the filters, calculations, Bins, etc.
Below is an example with a calculated field to mark in green the products that bring a profit higher than a threshold (the parameter defined by the user) and in red products with a profit lower than the threshold.
Dynamic Dimensions/Measures with Parameters
The most common use case for parameters is to create Dynamic views. This is done by making a selection of dimensions e.g. Sales by Country and Sales by Category. So we need to enable the user to select between the dimensions Country and Category. To do that we create a parameter “Choose Dimension” And a Calculated Field.
Then create the Calculated Field in which you define a CASE statement.
Actions
Add context and interactivity to your data using actions. Users interact with your visualizations by selecting or hovering over marks, or selecting a link in a tooltip menu, and the actions you set up can respond with navigation and changes in the view.
For example, in a dashboard showing the sales by product category, you could use actions to display relevant information for a selected product. Selecting a product sales in one view can trigger an action that highlights the product profit in another view, filters a list of the products, then opens an external web page showing information about that product.
Calculated Fields
When you create a calculated field, you are essentially creating a new field (or column) in your data source (the original data remains untouched) , the values or members of which are determined by a calculation that you implement. This new calculated field is saved to your data source in Tableau, and can be used to create more robust visualizations.
You can use calculated fields for many reasons. Some examples might include:
- To segment data e.g. IF, ELSE…
- To convert the data type of a field, such as converting a string to a date.
- To aggregate data e.g. SUM, AVG…
- To filter results e.g. with CASE, WHEN…
- To calculate ratios
To know what type of calculation to use, use the following questions:
Let’s check an example:
LOD (Level of Detail) calculation
We calculated the total revenue by product then we needed to calculate the revenue by category which needed to calculate the aggregation on the dimension category and we used for the the LOD: level of detail calculation
Common use case of LOD: Histograms to visualize customer order frequency (based on two dimensions).
I would like to have the data distribution of the nb of customers distributed by the number of orders. In this case we need to dimensions: the number of customers and the number of orders.
Since we have two measure we are going to use LOD.
Since we have two measures the number of Orders and the number of Customers we are going to turn the number of Orders into a dimension.
We are going to build something very similar to the vizualisation with LOD
Now to have the diagram number of orders by customer by Number of Customers which is a measure by measure that is not possible. You will have to turn the LOD Nr of Customers by Order into a Dimension and Discrete.
To have the histogram we need to turn the converted dimension Nr of Orders by Customer into Discrete.
Since we want to visualize the number of Orders over the years we add the Order date to the Rows to see how the order frequency distribution.
Histogram Interpretation — Custonmer Loyalty: We can conclude from the visualisation that most customers order 13 to 16 Orders and the frequency remained unchanged over the years.
Table Calculation: Running Total
The Running Total calculates the cumulative measure totals within a defines dimension, allowing incremental tracking in the data.
We want to track the progress of Customer and Orders by Month. To do that we take the categories in the rows and the Order date in the columns (it is a Dimension but we will turn it to a continuous Measure.
As we want to count the number of customers we add it to the Rows as well and make the visualization in bar. This way we get the total number of customers each month but not yet the running total.
We want to add the running total of Orders in the same graph (Dual Axis) and then we need to synchronise the right axis.
Now we come to the end of this article in which we covered the Calculations in Tableau as well as Actions and Filters. Make sure to view the first part of this services or article to have a complete overview about Tableau features and see you in the Third part!