Tableau practice tips

Zishen Li
12 min readMay 2, 2022

--

Tableau is one of the most frequently used visualization tools for Data Scientists and we all love its beautiful plot style. It is convenient when you want to see the trend very quickly, however, if you leverage this amazing tool to build a concise and clear dashboard for your stakeholder, you will need a deep understanding of the tool. Here are some tips I learned through my daily work that are worth noticing.

Actions and Buttons

Add click action for your plot

Most of the time you will use a filter to filter the data but you can also use an action to do the same thing. For example, when you have the category variable shown in different colors, you can click the color part to filter the data for the rest of your plot. Here is how you can realize it:

  1. Choose the plot you want to click on, from the navigation bar choose ‘Worksheet’ ->’Actions’. Click the low bottom ‘Add Action’ -> ‘Filter’

2. Name your filter as you like, here I will call it test1. Make the source sheet as the current sheet and the target sheet as the one you want to filter on. Here I use the ‘profit by order’ sheet as the source and filter on the ‘sales by order’ sheet.

You may want to change the ‘Run action on’ to ‘select’ and ‘clearing the selection will’ to ‘show all values’ which is what we usually do.

3. At the bottom, choose the selected fields as we only want to filter on certain fields. As we want to use ‘category’ in the ‘profit by order date’ sheet to filter the ‘sales by order date’, we choose the source field to be ‘category’ and click ‘OK’.

Then, back to the dashboard, when you click on one color in the plot ‘profit by order date’ it will filter that category in the plot ‘sales by order date’ for you.

Add a button to your plot

To make your dashboard more advance and a real interactive web page, a clickable button may be one of the best choices. In this section, I will add a button to my dashboard to show either sales or profit at once with the click of the buttons.

  1. Add a new sheet and create two variables ‘Sales’ and ‘Profit’ in plain English.

2. Type AVG(0) and AVG(0.0) in the columns to create two placeholders

3. put the newly created variables ‘Sales’ and ‘Profit’ into AVG(0) and AVG(0.0) tab separately.

4. Hide the header and change the format of the text and change the plot type to ‘Text’.

5. Put the new sheet on our dashboard and make it float. Change the fitting set to ‘Entire View’

6. Put either vertical or horizontal containers on the dashboard. Put both the ‘Sales by order date’ sheet and the ‘Profit by order date’ sheet into the same container.

7. create a parameter called ‘sales_profit’ in the newly created sheet as below. And create a calculation field that contains this parameter, so that we can use the field in the filter

8. Add the calculation ‘sales_profit’ to the filter for both sheets(sales and profit). Click the show parameter for ‘Profit by order date’ to ‘Profit’ and ‘Sales by order date’ sheet to ‘Sales’ and change the filter accordingly.

9. Add action to the dashboard, choose the one ‘change parameter’ and add profit action as below and add sales action the same way.

Now we can click the Profit and Sales button to change the plot to sales by order date and profit by order date accordingly.

If your title is the same you can choose to hide the title for one plot. Otherwise, you may want to change the title as well. In that case, you may need to create the plots in the same sheet(also with an additional filter of metrics we will touch it in the ‘More info for one plot’ section)and add the set/calculation in the title to get it changed.

You can also use a set to get the same function and you may also use different shapes for your button instead of plain English, the second video I listed below will show you how to do this in detail.

Find this really useful video on adding a button to go to another dashboard. And another one that uses the button as a filter for one plot.

All about date

Only include the complete week and calculate WoW%

When you show values on a weekly basis, if you include all data, the most recent uncompleted week will show weird value on the plot, which provides no or even negative info for your audience. In this case, we would like to only show the completed weeks. Here is how to do this:

  1. Create a new calculation field called ‘Completed Week’ using the below formula. This new feature will be 1 if that week is a completed one, 0 if not. We can then use this as a filter

2. Put the ‘Completed Week’ feature on the filters tab. Here to get the right calculation, we need to change the calculation field. We click on the drop-down of the feature and choose to edit the calculation, change ‘Compute Using’ to ‘Cell’. Then, we can choose the value of the filter to only include 1.

3. Finally to check we only include the completed weeks. We change the order date to week number and filter the end date to be 10/29/2021(any uncompleted week should be good). We will see now, the plot only show completed weeks end at the date of 10/17

To calculate the WoW%

To calculate the WoW%, we will first need this completed week of the metrics(here the profit) and the previous completed week of the metrics(here the profit).

  1. Create the current completed week metrics and previous completed week metrics

2. Create WoW% based on the above two helper features

3. Put the WoW% feature to the toolkit in the Marks tab for our ‘profit by order date’ sheet. We change the table calculation to ‘Cell’.

4. We may also want to show the WoW% in the label with a limitation. For example, when a profit of a category increased more than 50% from last week, this may give us an alert. To get this alert label, we need to create another new calculation field called ‘WoW% alert’ as below, in the definition, you can choose whichever limitation fits your business.

You can then add the alert and WoW% together to the label. You can also change the label color in the label tab(click the ‘…’ beside the Text). There are many icons you could use in Tableau. Here is a link for some of them.

Only show the most recent week's number

Sometimes we would like to have a summary table that shows the most recent complete week’s value. This section will show how to realize it.

  1. Create a calculation field called ‘Last’ using the below formula. I am adding ‘-1’ since we will use the complete week filter which filtered the most recent uncompleted week, however, when you use Last() it does count this row. You can also choose not to add the ‘-1’ and filter the value to only show 1 instead.

2. With this helper feature, we create a table with order data and profit and put the [last] to the filter tab. We then change the table calculation to ‘table down’ and select only show value ‘0’. With that now, we can only show the most recent completed week.

Show and filter by year, month, and week

In the section that only shows completed weeks, we use the order date filter with a range, we can actually use different types of filters for the date Tableau provides. Here is an example of the filter by year, month, and week separately for a single plot.

  1. Drag the ‘Order date’ to the filter tab. When you choose a range of dates, the filter will show as a slide bar. Click ‘edit filter’, and we can see there are five different types of filters. Be careful when you choose the range of the date, it won’t change the range as you fill in more data. So, typically I will use the starting date one.
  2. But for this example, we will choose ‘Years’ and choose all to include all data. Click the drop-down menu to show the filter, I will personally prefer a multiple dropdown form for my filter of year
  3. Drag the ‘Order date’ to the filter tab again and this time choose ‘Month’ and do the same as the year to get the ‘Month’ filter. So as to get a week filter.

Usually, when you put a year filter there, you may also want to put a month filter as well if your data are shown on a monthly basis so as the weekly basis data.

More info for one plot

Add percentage as you wish

If we have a colored bar chart, we may want to show the percentage of each color component. For example, we have a plot with profits vs. order date with category shown in color as below

  1. We drag the profit to the label button, click on the right ‘down’ button, and choose the ‘ Add table calculation’. Choose calculation type to ‘percentage of total’, computing used to ‘Table down’. Save the change the click on the label button choose to show the mark, we will have a plot as below

2. If you want to show both the percentage and the absolute number, you can drag another profit to the label button, and both of them will show. To format the label click on the label button and choose ‘edit label’ to modify there.

Show both total and segment numbers for the colored plot

When we use color to provide additional info in our plot, we may also want to show the total as well. Here is a plot showing the sales every month with category in different colors. The label shows the sales for each category but we may also want the audience know the total sales for that month more clearly(though you can always use tooltips to show that)

To show the total is quite simple:

  1. add another sales to the columns shelf and choose use dual axis by clicking the arrow on the right side of the sales bar, then the two plot will merge to one.

2. right click the axis on the right of the plot, choose sync the axis and hide the header

3. remove the category in the first ‘Sum(sales)’ tab on the left, then you will see the total number on the top of the bar

Add a conditional label for your plot(up and down)

There are two ways to change your number shown in the plot. One way we talked in the WoW% label section. Here, I would like to introduce another way which is more convenient but less flexible.

right-click on the number/plot, choose ‘Format’, click on ‘Fields’, and choose the variable you want to modify. (e.g. ▲ 0.#%;▼ -0.#% means in percentage format and show ▲ when the number >0 ▼ when number <0)

Edit your tooltip

To edit your tooltip, you will always need to drag that variable to the tooltip first, and then click on the tooltip, using insert to insert any variable you’ve already dragged in. The format of the number could be modified using the way talked in section ‘Style is important for changing the format of numbers. To change the color and font of the content of the tooltip, you can directly edit it by clicking the tooltip button.

Add a horizontal line for your plot

To add a reference line in the plot, click the analytics on the top left, drag the ‘add reference line’ to the plot, and choose the entire table and line as the format. Change the value to whichever fit your needs and the constant as your computation. customize the label and tooltip as you like(other useful references)

Add confidence interval for your forecasting

If you have a forecast on a certain metric, you may have a corresponding confidence interval from the model. But how to show that CI in tableau?

  1. calculate the bandwidth with the existing upper bound and lower bound(here I use profit as bandwidth and sales as lower bound)
  2. Put the ‘measure values’ in the ‘Rows’ shelf and put the lower bound and bandwidth into the measure values(bandwidth at the top). Choose Area in the Mark tile.
  1. put the measure names into the color and change the measure name’s color to lower bound: white(you can double click the name in the edit color console) and bandwidth: light grey

Choose metrics shown in one dashboard

If we want to show sales and profit in the same plot with a filter to choose from, here is how to realize it.

  1. create a parameter ‘Metrics’ like below to include sales and profit

2. create a calculation field with the same name ‘Metrics’ as below

3. put the metrics to the ‘Row’ shelf and ‘Order date’ to the columns shelf, click the parameter ‘Metrics’ and choose ‘show parameter’. Now, you can choose to show which metric you want in the plot by clicking on the filter in the upper right corner.

Fix one column when calculating total

https://help.tableau.com/current/pro/desktop/en-us/calculations_calculatedfields_lod_fixed.htm

Style is important

Change the format for your axis, label, and number

Axis: to edit axis range and title, right-click the axis and choose ‘Edit Axis’. To edit the format, right-click anywhere in the plot, and choose format. Change the format here will change the axis as well as the header of the plot

Label and title: If you choose to show the label in the plot, you can only change the format of the label by clicking the label button under the ‘Mark’ tab. To change the content and format of the title, double click the title and modify it there.

Numbers: right-click anywhere in the plot, and choose format. In the format tab, choose the variable you want to modify in the upper right corner and change the format as you like. You can also customize the format of the number with an up or down triangle as the number is larger or smaller than 0.

--

--

No responses yet