Skip to content

Create a parameter from the calculated field Tableau

  • by

To create a parameter from the calculated field Tableau, you must use the result of a calculated field to define the parameter values dynamically. Here’s a step-by-step guide to achieve this:

2. Create a parameter from the calculated field Tableau

Create a Calculated Field:

  • First, you need to create the calculated field that will provide the values for your parameter.
  • Go to the Data pane, right-click on your dataset, and select Create Calculated Field.
  • Enter a name for the calculated field and define your calculation. For example, if you want to create a parameter based on a range of dates:
  • Click OK to create the calculated field.

The calculated field below retrieves the minimum Order Date, which represents the earliest date among all the other orders.

MIN([Order Date])
Create a parameter from the calculated field Tableau
Create a parameter from the calculated field Tableau

Create a Parameter:

  • Right-click on Parameters in the Data pane and select Create Parameter….
  • In the Create Parameter dialog:
    • Name: Enter a descriptive name for your parameter (e.g., “Dynamic Date Parameter”).
    • Data Type: Choose the correct data type that matches your calculated field (e.g., Date, Integer).
    • Current Value: Set an initial value that makes sense for your parameter.
    • Allowable Values: Choose the Range or List depending on your needs:
      • Range: Define a minimum and maximum value based on your calculated field.
      • List: If using a list, you’ll need to input values or use a dynamic approach to update the list.

Link Parameter to Calculated Field:

If you’re using a Range:

  • Set the minimum and maximum values of the parameter as the result of your calculated field.
  • For example, Since our calculated field created in the previous step is based on the “Order Date” you can establish the minimum and maximum range using the values from the “Order Date” field:
    • Minimum: MIN([Order Date])
    • Maximum: MAX([Order Date])
Create a parameter from the calculated field Tableau
Create a parameter from the calculated field Tableau

If you’re using a List:

You’ll need to update the parameter values based on the calculated field results. You can click on the “Add values from” dropdown and select the “Order date“.

Create parameter from calculated field Tableau
Create a parameter from the calculated field Tableau
  1. Show Parameter Control: Right-click on the parameter in the Data pane and select Show Parameter Control to display it on your dashboard.
  2. Use the Parameter in Calculations: Create or update calculated fields to use the parameter. For example, to filter data based on the selected date.

In the image below, our Calculation1 field compares the Order Date with the FROM_DATE parameter. Because FROM_DATE is determined by the calculated field (MIN([Order Date])), it only selects the order date that is less than the minimum value of the other orders.

Create parameter from calculated field Tableau

In the visualization below, we can see only the order with the earliest order date.

Example Use Case

Suppose you want to create a parameter that allows users to select a date from a dynamic range of dates available in your data:

  1. Create a Calculated Field for the minimum and maximum date: MIN([Order Date])or MAX([Order Date])
  2. Create a Date Parameter: Set the minimum and maximum values of the parameter based on your calculated fields.
  3. Apply the Parameter in visualizations to filter or adjust data dynamically based on the user’s selection.

3. Summary

To create a parameter from a calculated field in Tableau:

  • Create a calculated field that provides the values you need.
  • Define a parameter with the right data type and values based on your calculated field.
  • Use the parameter in calculated fields and visualizations to leverage the dynamic input.

To learn more about Tableau, refer to our articles. Our code samples are available in our GitHub repository.

Leave a Reply

Your email address will not be published. Required fields are marked *