Parameter to Switch Between Year, Month, and Day

by Skomantas Tamulaitis

In Tableau you can let the user choose what part of the date they want the chart to be showing. Here I will show you how to do it using parameters. The data for this example is taken from Tableau’s Sample – Superstore dataset.

Step 1
First, you need a parameter for your columns. Create a parameter, select “String” as data type and click on “List”. Change the name to “Column Parameter”.

Step 2
Now you need to specify the part of the date that you are interested in. I want to be able to see date at week, month, and year levels so these are the three values I put in the parameter. Spelling is important here, the text on the left side under “Value” column will be used in a calculated field so make sure to keep it lower case. The text on the right side under “Display As” column will be shown to the user in the parameter so make sure it is in the format that suits you. You can click on any cell and edit the text there. I will edit it so each word is capitalized.

Step 3
Click OK, then right click on the parameter and select “Show Parameter”.

Step 4
Create a calculated field and call it “Date Part for Columns”. Type in the function DATENAME(). Within the brackets add your "Column Parameter" and date field separated by a comma. Here I am using Order Date.

In this function the first argument (your parameter) specifies what level of date you want to look. The second argument (date field) specifies which field you want that calculation to refer to.

Step 5

Place the calculated field “Date Part for Columns” on the columns and drag "Sales" onto rows. Now if you change the parameter the graph will change accordingly to show the graph at the level of date that you are interested in.

Avatar

Skomantas Tamulaitis