25 Apr Parameters in Tableau
Parameters in Tableau are referred to as containers of values used to calculate and effectively enter values not present in the original dataset. These parameters can include workbook variables like dates, a string of text, a number, or a calculated field which can be used to replace the constant value in a filter or calculation.
We can also add conditions and put in a range of values for which we want to create a parameter. After that, we then incorporate these values into our reports and dashboards so we can see each change.
In this tutorial, we’ll demonstrate what the Date Field Parameter is.
Date Field Parameters in Tableau
Working with Date Parameters in Tableau helps to give users the flexibility to change date levels from years to months, from months to weeks, or from weeks to days. We’ll show this with an example below;
Step one
Open Tableau on your computer and open a new worksheet; we will use the Superstore Dataset.
Now, drag the Order Date
to the Row Pane on the working area and drag the Sales
to the Text under the cards. Ensure to select Table under Show Me, so it won’t be displayed as a chart.
Step Two
We have each sales value per year, what we need to do is create our Parameter. We will do that by clicking the arrow icon in the top left corner and selecting create parameter option as shown in the image below.
The dialogue box appears and we will put in a Name(Dates Params) and select the datetype as a string. Select the list option and put in each of the values(Year, Quarter, Month, Week, Day) and press Enter Key. Follow what we did in the image below and select OK.
You will see your Parameter below the Measure Fields and right-click on it. Select Show Parameters which will be displayed on your working area for easy navigation.
Step Three
The Parameters we created aren’t in use yet except that we have to reference them in a calculated field. In this calculated field, we will select each of the fields (Year, Quarter, Month, Weeks, and Day) to match their actual calculation, so it can display each sale we have per year, quarter, month, week, and day respectively.
1CASE [Dates Params ] 2 3WHEN "Year" THEN STR(YEAR([Order Date])) 4 5WHEN "Quarter" THEN STR(YEAR([Order Date]))+"/Q"+ DATENAME('quarter', [Order Date]) 6 7WHEN "Month" THEN DATENAME('month',[Order Date])+""+STR(YEAR([Order Date])) 8 9WHEN "Week" THEN "Week" + STR(DATEPART('week',[Order Date])) 10 11WHEN "Day" THEN STR(DATE([Order Date])) 12 13END
After this, we will click on the Show Me tab to change the view from Table to chart. Thereby, we can navigate to different charts using our Parameters.
If you found this post helpful, let us know in the comments box.
No Comments