How to Use Parameters in Tableau Prep to Easily Scale Workflows
In Tableau Prep, you can use parameters to scale your flows to accommodate multiple use cases instead of managing duplicate flows! Introduced with the Tableau Prep 2021.4.1. release, parameters are global placeholder values that you can use to replace constant values in a flow. Easily swap out input or output values that use the same schema when running or scheduling a flow, or use parameters in filters or calculated fields to edit values throughout your flow.
Parameters give you the power to make your prep flows dynamic. In this post, I’ll be walking you through how to use parameters to dynamically filter sales data. Using parameters in this way empowers anyone to easily use your flows without having to understand the technicalities of the flow.
Dynamically filter sales data with Parameters
In this example, we'll be using the Superstore sample data set. Open the data set, then to create a new parameter, click the Parameter icon on the top menu, then click Create Parameter.
Name the parameter “Year of Sale.” Then, set the data type to “Number (whole)” and select “List” as the allowed value type. This will allow whoever runs the flow to choose the parameter value from a preset list of years. Add years 2015 through 2018 to the list, then select “Prompt for value at run time” to require anyone running the flow to choose a parameter value from the list.
After creating the “Year of Sale” parameter, you can apply this parameter to steps in your flow. To see all the places you can apply parameters in a flow, check out our Help documentation Apply Parameters to Your Flow.
To use the parameter to filter order data by year of sale, add a new filter that checks if the [Year of Sale] field is equal to your parameter value. Notice that the parameter value is highlighted in purple, whereas the field is shown in orange, just like in Tableau Desktop.
When you save this filter, the data is dynamically filtered to only include sales data from the year the parameter is set to.
To keep track of the sales data included in the output, navigate to the Create ‘Superstore Sales.hyper’ output step and use the parameter to replace the end of your file name with the year of sale. It's as simple as clicking the parameters icon and choosing the parameter to apply.
When it’s time to run the flow, you will be prompted to choose a parameter value to run the flow with. Select 2015 from the drop-down, then click “Set” to apply the parameter value and run the flow.
To run the flow for different data, run the flow again, then when prompted, enter the parameter value “2016.” Notice that the output step updates with the different data depending on the year chosen, and now you have generated two outputs: Superstore Sales from 2015.hyper and Superstore Sales from 2016.hyper.
In prior releases, you had to manually dig through the flow and tediously change values used throughout or maintain duplicate flows. Furthermore, this required knowledge of the steps in the flow. But, with parameters, using this flow to generate different segments of sales data is as easy as two clicks—helping more people in your organization see and understand their data, faster.
Parameters can also be leveraged to transition your Prep flows from test data to production data. This is useful for when you want to validate that a flow transforms your data properly before overwriting any downstream artifacts. The possibilities are truly endless, and we can’t wait to see the creative ways the Tableau community will use parameters to solve their data problems!
Want to learn more?
For more information, see our Help documentation for Tableau Prep Parameters. Eager to learn more about how to use Tableau Prep? Head over to the Tableau eLearning site and check out the Prep Builder course!
관련 스토리
Subscribe to our blog
받은 편지함에서 최신 Tableau 업데이트를 받으십시오.