Are you interested in making your visualizations more dynamic? Enter Tableau parameters! Parameters allow the end user to single select a value from a list or range of values. In this example, we'll show how to use a parameter to change the measure and reference line value. 1. Open a data source, such as Sample – Superstore.xlsv 2. Drag Orders onto the data canvas 3. Create a new worksheet titled Dynamic Reference Line 4. Drag Order Date onto the Columns Shelf and aggregate at month as a date value 5. Create a new Parameter called Select a Measure 6. Set Data Type to String and use a list for Allowable Values 7. In the List of Values area below, enter Sales and Profit As always, a parameter needs to be used in conjunction with either a filter or calculated field. 8. Create a new calculated field titled Measure Select Calculation; edit as shown below: This calculated field instructs Tableau to determine what the parameter value is set to. If it’s set to sales, return SUM (sales); if it isn’t, return SUM (Profit). 9. Drag Measure Select Calculation to the Rows Shelf 10. Right click the Measures Parameter and select Show Parameter Control The measure displayed is now determined by what the parameter is set to. We’ll use a similar concept to create the dynamic reference line. 11. Create a new calculated field called Target Line; edit as shown below: This calculated field instructs Tableau to determine what the parameter value is. If the parameter is set to “Sales”, return a value of 100,000; if the parameter isn’t equal to “Sales”, return a value of 10,000. 12. Drag Target to the Level of Detail and change the aggregation to AVG 13. Right click on the Y-axis and select Add Reference Line 14. Select Line as the Reference Line type & Set Scope to Entire Table 15. Under Line, use the Value drop-down menu to select AVG (Target Line) 16. Use the second drop-down menu to change the Aggregation to Average 17. Set Label to Custom; in the box to the right, type Target: 18. Click the right arrow next to the drop down menu and select Value The Reference Line settings should now look like this: 19. Click OK to return to the view
Tableau now displays a reference line based on the parameter selection.
0 Comments
|
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
March 2019
Categories |