Skip to main content

Filtering in Tableau with parameters

Filtering in Tableau with parameters


Scenario here is the dashboard he was working on utilized multiple datasources and to filter all of the sheets in the dashboard by Year. Ordinarily when using multiple datasources, wewould have to utilize a Quick Filter for each individual datasource. Given that there are and find a way to achieve the same functionality, but with only one Quick Filter instead of four.
Note: if you are new to Tableau, this is what a Quick Filter looks like. It allows users to slice and dice data interactively.
There are many ways of solving this, whether through Data Blending or Dashboard Actions. In this case though, those options would cause problems with existing functionality, so I decided to go with parameters as filters.
Parameters are extremely simple – they allow users to select or input a value. That value can then in turn be used in calculations, and subsequently, filters. You can even set the values that users can select to be automatically created from a field in your data, which saves time.
In this situation my goal was simple. I wanted to create a parameter that would allow users to select a year, and then create a calculation that would use that parameter to filter to the selected year. Here is what I did - if you want to practice on your own, you can follow these directions using the Superstore and CoffeeChain datasets that come pre-loaded in Tableau (just click “Connect to Data”). Begin on the CoffeeChain datasource.

1. Create a parameter called ‘Year’ and give it a list of years applicable to the worksheet

  • Right-click the Data Window and select “Create Parameter”
  • Set the Data Type to “String” and the Allowable values to “List”
  • Note: Because the two data sources have two different date data types (Superstore Sales: Date and Time, CoffeeChain: Date) we cannot set our parameter to a date data type for it won’t be compatible to both. In cases where all data sources have the same date data type, the parameter can be set to that data type.
  • Inside the list, set the years the Year parameter should have access to within the data source and click OK to create the parameter.

2. Create a calculated field which will get the string version of the date’s year

  • Because the data source’s date field has a date and time data type, we need to create a string version of the year to be able to compare it to the parameter just created, which was set to string.
  • Right click the field “Date” under dimensions and select “Create Calculated Field”
  • Name the Calculated field the data dimension with ‘Year’ added at the end. Wrap the date dimension field in the Formula window in string (STR()) and year (YEAR()) functions and select OK to create the calculated field. This calculation will always result in the year of the Date field.

3. Use the calculated field as a filter and link it to the Year parameter

  • Drag the newly created calculated field (“Date Year”) to the Filters view card and a filter box will appear.
  • Under the General tab, select “Use All” to use all of the different years in the data source and select the Condition Tab.
  • Select the “By Formula” option and click the “…” button to open the formula creation window. This is where the calculated field and parameter will be linked.
  • Set the calculated field (Order Date Year) to equal the parameter (Year) and click OK.
  • Click OK once more to create the Filter based on the calculated field which is linked to the parameter.

4. Enable users to select values using the parameter

  • Right click the Year parameter and select “Show Parameter Control”.
  • Select the black dropdown arrow located at the top right of the Parameter Control panel and select the “Slider” option.
  • Open the dropdown menu again, select customize, and select “Show buttons” to remove the buttons from the control panel.
  • Note: There are many options to choose when customizing the control panel. Explore the different options until a panel is created that is appropriate for the purposes of the filter.

5. Repeat step 2 for every data source that will have a date dimension that needs to be filtered.

6. Repeat step 3 for every sheet that will need to be filtered by its date.

In the dashboard, every sheet that has a filter linked to the Parameter will be affected when the parameter control is changed. It takes a couple moments to set up, but the end result is clean and easy to use, as you can see here.

Comments

Popular Posts

Add Space between bars in Tableau chart

Add Space between bars in Tableau chart Scenario: Tableau defaults to no spacing between the panes in a view. How do I get some spacing between groups of bars in my charts? It can be achieved through the steps below: Add subtotals (Analysis->Totals->Add All Subtotals) Right click on the measure pill on the Rows shelf and change the default SUM() aggregations to MIN() To edit the color legend – double click on the Total color, this takes you to a color dialog, select the WHITE color, click OK Right click on the word Total in the X axis and select Format In the Format window, click the Header tab and blank out the Total label field The added space looks like below:

Adding “Apply” Button to A Filter Menu In Tableau

Adding An “Apply” Changes Button To A Filter Menu In Tableau Sometimes when a user is changing the options they want on a filter in Tableau, the chart updates as they change each option. This might not be the best user experience if they are changing many options and don’t want the dashboard to redraw the view until they have completed their selection. It is very simple to fix this – Tableau includes an “apply” changes option, which when enabled, means the dashboard won’t redraw to reflect the new filter choices until the user presses the “apply” button. Simply click the drop down arrow on the filter menu > go to “customize”, then click “show apply button”.  

Error "Cannot mix aggregate and non-aggregate arguments with this function"

Error "Cannot mix aggregate and non-aggregate arguments with this function" When Creating a Calculated Field When creating a calculation, the following error might occur:  "Cannot mix aggregate and non-aggregate arguments with this function." The issue can be resolved through one of the below options: Modify the calculation so that all fields are either aggregate or non-aggregate. Each option can result in different values (please reference the additional information section for specific examples). Option 1 (Aggregate Then Divide) Wrap all fields in an aggregation. Sample: [Profit] / SUM ([Sales]) -> SUM ([Profit]) / SUM ([Sales]) Option 2 ( Divide Then Aggregate) Remove aggregations from all of the fields. Sample: [Profit] / SUM ([Sales]) ->[Profit] / [Sales]   Option 3 ( Condition Then Aggregate) Move the aggregation so all fields are aggregated. For example, the calculation: IF [Row ID] = 1 THEN SUM( [Sales] ) END  could...

Removing "Abc" Placeholder Text in Tableau Measures column

Removing "Abc" Placeholder Text in Tableau Measures column Quick and easy fix for this issue could be: Use Polygon mark type On the Marks card in the dropdown menu, select Polygon Resize the last column to make it smaller Navigate to Format > Borders In the left-hand Format Border Pane, for Column Divider, For Pane, select None from the dropdown menu Navigate to Format > Shading In the left-hand Format Border Shading, for Row Banding, move the slider to the desired level of row banding

Tableau Bar Chart Rounded corners

Tableau Bar Chart Rounded corners Follow the steps in the video below to create rounded corners for the bar chart:

Using Special Characters in Tableau URL Parameters

Using Special Characters in Tableau URL Parameters When we try to use special characters in URL parameters, the URL parameter might not do anything, or an error might occur. The issue can be resolve by:  Use one of the following workarounds: Replace the special character with the URL encoding sequence for backslash (\) (%5c) followed by the URL encoding sequence for the special character. The backslash is needed to escape the special character. For example, the URL encoding sequence for backslash and comma (\,) is %5c%2c.  In the data source, separate comma-delimited field values into separate columns that can be filtered independently. In Tableau Desktop, use a calculated field to replace the special characters, such as commas or spaces, with hyphens (-). Cause The browser cannot parse the special characters used in the URL. Additional Information The error varies depending on the browser and special character being used. Networ...

Cannot mix aggregate and non-aggregate arguments with this function

Cannot mix aggregate and non-aggregate arguments with this function Issue When creating a calculation, one of the following errors might occur:    "Cannot mix aggregate and non-aggregate arguments with this function." (Option 1,2,3 or 4 can be used). " All fields must be aggregate or constant when using table calculation functions or fields from multiple data sources." (Option 1 or 3 can be used). "Argument to sum (an aggregate function) is already an aggregation, and cannot be further aggregated ."  (Option 2, 3 or 4 can be used). Environment Tableau Desktop Resolution Each option can result in different values (please reference the attached workbook in the right-hand pane and additional information section for specific examples). Option 1 (Aggregate All Fields) Wrap all fields in an aggregation. Sample: [Profit] / SUM ([Sales]) -> SUM ([Profit]) / SUM ([Sales])   Option 2 ( De-aggregate All Fields) Remove aggregations from all of ...

Set a Date Filter Default to Max Date in Tableau

Set a Date Filter Default to Max Date in Tableau Some of us might have not noticed the setting a   filter to default to the Max date. There is a quick and simple option to achieve this in Tableau filters. Follow the steps below: 1. Create a date filter with the date dimension. 3. Drag the date dimension to filters pane. 4. Edit the date filter to Select from the list and select the max date available. 2.    Now, y ou have the option  'Filter to latest date value when workbook is opened', check this box and click on OK.

Tableau Extract Update Error "Timeout Error: IPC_NamedPipe::Select(WaitForMultipleObjects)

Tableau Extract Update Error "Timeout Error: IPC_NamedPipe::Select(WaitForMultipleObjects) When trying to update the Data Source or w hen attempting to connect to a data source, or create and/or refresh extracts with Tableau Desktop, the following error message occurs:  IPC_NamedPipe::Select(WaitForMultipleObjects): Timeout. Cause Anti-virus software is blocking Tableau processes from running, or the Logs folder contained corrupted information.  Resolution Option 1: If it is easy w ork with IT helpdesk/support to add below Tableau folders and processes to exclusions : Tableau.exe hyperd.exe hyperdstarter.exe *.hyper extension (if AntiVirus has an option for extension exclusions) C:\Users\<username>\Documents\My Tableau Repository C:\Users\<username>\AppData\Local\Temp\TableauTemp C:\Users\<username>\AppData\Local\Tableau C:\Program Files\Tableau Make sure that child folders are included in the exclusions. AntiVirus prog...