top of page

Action Filters, Animations and Calculated fields in Tableau.

Updated: Jun 1, 2023

In this blog we will be discussing in detail about how to add action filters and animations in charts and how to make calculated fields in Tableau.


This blog adds to the previous blog i.e. Creating dashboards in Tableau and hence, it should be noted that the same dataset will be used. You can download the dataset from below.




Action filters


In a previous blog ( 'Creating a dashboard in Tableau') we learned how to use charts as a filter for other charts. We will take it a step further and explore what all actions can be performed using filters.


Firstly, instead of all the charts, the change can be reflected in a selected few charts as well. For this, instead of making a chart as filter in the dashboard we have to set interactions in the worksheets.



For example, in the Dashboard shown above. If we make 'Sales by Region' chart a filter and only want to reflect the change in the 'Sales and Profit' chart, then we have to follow the steps given below:


step 1: Select the target chart (the chart in which you want to reflect the changes) which in this case is 'Sales and Profit' chart and then from the menu bar select the 'Worksheet' tab and then select the 'Actions' option. An 'Actions' dialogue box would appear.



step 2: In the dialogue box click on the 'Add Action' button and select 'Filter' option from the dropdown menu.



Here, I would like to mention that you can choose other actions as well.

  • If you will choose 'Highlight' action. Then the data corresponding to the selected field in the source chart will be highlighted in the target charts instead of being filtered.


  • If you select 'Go to URL' or 'Go to sheet' action you can add a link to a web page or a site and a tableau sheet from the current workbook respectively to your charts.


  • If you select 'Change Parameter' action, then it lets viewers to change a parameter value through direct interaction with a viz, such as clicking or selecting a mark.

  • If you select 'Change Set Values' action, then the values corresponding to the selected set of marks in the source chart will get reflected in the target charts. Moreover, for selecting you can use a pan select, lasso select, a rectangular select or a radial select.


step 3: In the 'Add Filter Action' window that appears, in the dropdown menu of Source Sheets select the current Dashboard and do the same in the Target Sheets section. This will display the available charts in the dashboard in the view pane. Just select the charts you want to be the Source chart ( in this case: 'Sales by Region) and the Target chart (in this case: 'Sales and Profit').

You can select the cursor option by which you would like to reflect the change using the 'Run action on' option which provides three options Hover, Select and Menu. The terms are self-explanatory. In this case we have opted for 'Select' option.


You also choose what would happen to the charts after you clear the selection i.e. whether you want to keep showing the filtered version or show/exclude al the values using the radio buttons in the Target sheets section under the 'clearing the selection will:' option.


After selecting the desired options click on the 'OK' button.



And with this we are done. If you will now select a region in the 'Sales by Region' fill map then the sales and profit corresponding to that region would get reflected in the 'Sales and Profit' chart only. There would be no change in the 'Sales by category' tree map.



In a more or less similar fashion you can apply other actions ( discussed in step 2) to your charts to customize your dashboards.



Animation


To make your charts stand out you can add animation to them.


In order to understand the steps involved, lets try to animate a sales trend chart over time.


Step 1: Make a monthly sales trend chart. If you don't know how to please check out this blog.


Monthly Sales trend chart

Step 2: Drag the ' Order Date' field from the Data pane to the 'Pages' card and make it monthly as shown below.



The chart now shows the data of January 2016 only.

Step 3: Go to the animation tab in the top right corner and click on the play button. You will see that the chart would be animated to show the data of each month corresponding to a year in a one by one fashion as shown below.



Step 4: To make the animation more interesting. We will draw the trajectory of the data point. That is we will keep showing the history as the data mark advances from one point to another.


To do this, first change the data mark from automatic to circles from the dropdown menu of the marks card. Then go to the animation tab and check the 'Show history' option. The animation would be as shown below.



Note:


  • You can increase or decrease the speed of the animation using the three buttons on the RHS of play button.




  • You can also reverse the order of animation using the button on the LHS of the stop button.




OR


We can draw a line showing the path traversed by the data mark as it progresses. To do this select 'Trails' option from the show section in the dropdown menu of 'show history' tab.


The animation will transform as shown below.



Try animating some other charts and see how it goes.



Calculated fields


You can also create required fields on the go in Tableau, in a similar manner as we do in excel.


With calculated fields we can create new data field from data that already exists in the data source. Creating a calculated field, make a new field (or column) in the data source, whose values are determined by a calculation that we perform. This new calculated field is saved to the data source in Tableau, and can be used to create more robust visualizations. But not to worry because our original data remains untouched.


Following are some of the cases where you can use calculated fields.

  • To aggregate data

  • To segment data

  • To convert the data type of a field, such as converting a string to a date.

  • To filter results

  • To calculate ratios


Lets create a calculated field to get familiar with the process. We will go through a simple example of making a 'Unit Price' field, the name of the field is self-explanatory, we will calculate the unit price of all the products for which we will use aggregate calculations.


On the top right corner of the data pane there is a dropdown menu, click on it and select 'Create Calculated fields' option. A dialogue box would pop up.



Give the field a name, here we will name it 'Unit Price'. In the blank space below, we will type the formula to create the desired calculated field. Here, we will divide sales by quantity to get the unit price. But we need to aggregate this calculation, therefore, we will use sum of sales and sum of quantity as shown below. Then click okay.



You will notice that the calculated field now appears in the data pane. NOTE : to get a list of available aggregate function you can click on the triangular icon along the right edge of the dialogue box. This will open a menu, from its dropdown select the 'aggregate' option and then a list of available aggregate functions would appear ( apart from aggregate there are many other categories of available functions in the dropdown menu, do check them out.)


Lets use this field to plot unit price of each subcategory.



Similarly, you can create calculated fields as per your requirements.


This blog ends here, if you have been following this series of Tableau blogs, then you know that we have explored almost all the important topics so far. You can explore more and play around with these features, with more variation you can create amazing visuals.


You may also be interested in the following blogs:


If you need implementation for any of the topics mentioned above or assignment help on any of its variants, feel free to contact us.











留言


bottom of page