Monday Minis: Dynamically Show/Hide Parameter so it Only Appears When Relevant

I was recently working with a client who had a need to visualize a metric 1 for a geographic area compared to either metric 2 for the same geographic area or metric 1 for a comparison geographic area. A user would choose which comparison they wanted from a parameter (primary geographic area metric 2 or secondary geographic area metric 1). However, when the client selected the first option (comparing metric 1 and 2 for the same geographic area), they didn’t want the comparison selection parameter to show because it didn’t have any relevance. So we needed a way to essentially “hide” the parameter and only show it when it was needed.

So imagine we are using Superstore in Tableau. I want a user to be able to view Sales for a selected State, let’s say Ohio, compared to that same state’s profit and I have parameters to select the State and change the comparison. As noted, we also need users to be able to select the comparison State when relevant. We would see something like this with all three parameters. You can see the last one says Pennsylvania, but that state isn’t even in the view, so it’s a bit confusing. Ultimately, when the comparison measure is set to “Primary State Profit” we don’t want to see the comparison state parameter selection.

So how can we hide it? Well we can use collapsing worksheets and a bit of Tableau trickery. You can view and download the accompanying workbook here. Let’s go through the simple steps.

STEP 1. Create a hide parameter sheet

  • Create a Blank calculation that only includes quotations
  • Drag the Blank calculation onto text and onto rows, then format so no lines are in the view and it appears blank (remove tooltip)
  • Place the parameter that will essentially trigger if the second parameter shows or not onto filters and check off the value that will show the second parameter.

STEP 2: Containers

  • Drag out a horizontal container and place both the main parameter and the one that you want to show only when relevant (in this case the Comparison State) into it. Then place the Hide Parameter Sheet in between the two parameters.
  • Fix the width of the two parameters to each 1/3 of the total width of the container. Do not fix the width of the Hide Parameter Sheet.

STEP 3: Float the last parameter

  • Float a blank white object over the Hide Parameter Sheet
  • Float the parameter that will determine if the second parameter will show or not over the Hide Parameter Sheet and blank object.
  • Now when the parameter changes the Hide Parameter Sheet will disappear which will cause the second parameter to shift to the left and be obscured by the blank object and the triggering parameter.

Below you can see how the viz looks when the comparison state parameter isn’t needed. We only see the two that are relevant.

Upon changing the comparison parameter, the comparison state parameter appears as the Hide Parameter sheet expands and thus moving the parameter into view. Pretty slick right?

So that’s how you can hide a parameter without adding any additional clicks or show/hide containers, etc. That being said, Kevin Flerlage does have a blog post about that exact technique, so if you want to use buttons instead, you can check out his post here.

As always, let me know if you have questions!

Cheers,

Lindsay

3 comments

  1. hello Lindsay. How can I do the same when I need to hide 5 different dropdowns based on Main Parameter which has 5 options.
    1. So the first option by default is showing CompSet, all the other dropdowns should be hidden.
    2. the Second option in the Main Parameter is the Market. When I select this option, just the Market Name dropdown shows up.
    3. the Third option is Submarket. When I select this option, just the Submarket Name dropdown shows up.
    4. the Fourth option is the Other Property. When I select this option, just the Property Name dropdown shows up.
    5. the Fifth option is Time Period. When the user selects this option, Month and Year dropdowns should show up.

    Market, Submarket and Property Name dropdowns are sets. I need to use sets.
    Month and Year are parameters.

    Thanks.
    EL.

    Like

    1. While I haven’t tried this, I would imagine you could do the same concept but you would need a few containers and blank sheets that populate when the selected parameter value is selected. I’m imagining the 5 parameters each in a vertical container with the parameter and the blank worksheet above it. Then one long blank floating over the top portion of the 5 containers. The calcs for the worksheets would need to be dependent on each parameter as you mentioned.

      Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s