• Dynamically Set Default Values for Quick Filters in Tableau

    Recently, I was helping someone with a Tableau dashboard in which an action from the first view filtered a second view.  The second view additionally had a quick filter and that quick filter set to show only relevant values.  Something like this:

    But, try setting the drop down quick filter option to “Medium” and then select “Express Air”.  Notice that “Medium” never occurs with “Express Air”.  The result is all data filtered, a blank view, and the drop down filter shows “(Medium)” – it’s in parentheses to let you know that the filter value isn’t relevant.

    And, I can confirm that with a quick view:

    Confirmation

    Indeed, not all ship modes use all priorities.

    Now, the question arose: Can we get the quick filter to default to a certain value based on the Ship Mode selected?  That is, can we set a default value for a quick filter based on an action?

    Don’t be too quick to say, “No!”  That was my first inclination.  But I was wrong… There is a way!

    And I’ll tell you next time…

     

     

    ha!

     

     

     

     

    …Just kidding!  I’ll tell you now:

     

    Setting Default Values for Quick Filters

    Let’s say I identify the following values that I want for the defaults of the quick filter drop down based on my selection:

    desired default values

    Here are the steps I took:

    1. Create a field that gives me the default order priority for each Ship Mode. I could do this in the source.  I chose to do this as a row-level calculation.  It’s important that it’s row level and not aggregate, because I’ll need to eh field to be classified as a dimension (so no blending for the default either).

    Calculated field to set default for each Ship Mode

    1. Make sure the field is in the view that will trigger the action. Here, I’ve just added it to the detail of the Marks card:

    Add to Detail

     

    1. Then I create a new, separate action in the dashboard that maps Default Order Priority from the source sheet to the Order Priority field of the data source for the target:

    Action Filter Options

    Notice that I’ve specified the Target Filters to specifically map the Default Order Priority to the Order Priority.

     

    After triggering the actions on the dashboard, you can look at the target view sheet and see that the Actions are applied as filters:

    Action Filters in the View

     

    So, the final trick to dynamically set and change the quick filter value is to use the Action filter as a quick filter instead of the original field.

    To do this, locate the little drop down caret and use the menu to add the quick filter for the Action:

    The little drop down caret

    And now, you have a dynamic quick filter with default values based on the selection!  Experiment below:

     

     

14 Responsesso far.

  1. Mike Klein says:

    Hi Joshua,

    Great article as always. I’m noticing that you are getting an error on the blog page from the server: //drive.google.com/file/d/0B0k64Ucxl99-S3UzZTM0RHdXa3c/view?usp=sharing

    If this is a Tableau bug, I’d be very interested in following up.

    MAK

  2. Matt Lutton says:

    So cool; thanks for sharing Joshua!

  3. Ross Bunker says:

    You might be able to use an LOD calc like so:
    { fixed [Ship Mode] : MIN([Order Priority]) }
    to dynamically chose the ‘default’ rather than having it be a hard coded CASE WHEN calculation.

    • Joshua Milligan says:

      Yes, that would be really cool. You could even use LODs to determine the Order Priority with the most or least number of orders (or highest or lowest profit). It would be something like this.

  4. Mitesh Parekh says:

    Thanks for sharing as I was looking for something similar, I applied your approach but it didn’t work for my scenario.(your approach works otherwise).

    I did post my question in tableau forum hoping for some answers. (https://community.tableau.com/thread/196407)

  5. Emily says:

    Hi Josh! Great solution! Is there a way to only include only relevant values here as well as having the default?

  6. SKP says:

    Is it possible to show top 12 values in a filter by default and the users can pick more than 12?

  7. yvan fornes says:

    Very useful. You saved my day. Thanks Joshua

  8. David says:

    This is great. Thank you so much. I was able to select the defaults I wanted.
    Would it be possible to adjust the quick filter option list based on the category chosen? Basically, each category in my project has three or four options associated with it, and I only want the relevant ones to show.
    While I could get this dynamic filter list to work before, I end up breaking that ability when I apply your method. Any adjustments you’d recommend?

    • benmelek_admin says:

      Hmmm… I’m not sure right off. Would it be possible to post the workbook on the Tableau forums with your question? Ping me and I’d be happy to take a look.

Leave a Reply

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