Online tableau training, tableau tips, & video tutorials
Exercise: Highlight a Dimension Member Using a Parameter ControlPreview
Create a sorted bar chart and highlight a specific mark
In this self-guided exercise, you will create a sorted bar chart and a highlight effect that allows users to focus on what is most relevant to them. Hint: You will need both a parameter and a calculated field.
Hi, this is Ryan with Playfair Data TV, and in this self-guided exercise, you’re going to highlight a dimension member throughout a chart in Tableau. You’re also going to allow the end user to choose which dimension member is being highlighted. Let’s take a look at the chart, what you need to rebuild.
The first foundation of this is very simple. Hopefully its review for you at this point. If it’s not, check out the video related to how to make a bar chart. But we’ve got Sales drawing in a y-axis, which means it is on the Rows Shelf. And then we’ve got a dimension called Sub-Category on the Columns Shelf. So Sales by Sub-Category, these are sorted in descending order. That’s the foundation.
What’s new and what you’re going to be doing in this exercise is you’re going to be adding a highlight that helps orient the end user with what is most relevant to them. You will eventually need a dropdown up here. I’m giving away a hint there. It says Sub-Category Parameter. So yes, this is built with parameters and this is a parameter control.
When you make a different selection, it will change what is being highlighted on this bar chart. Go ahead and pause the video. Take a shot at this. When you’re ready for me to help you out, click the Play button. All right. Let me show you how this was done. First, again, the foundation.
We’ve got Sales by Sub-Category as a bar chart. Well, I happen to know a couple of defaults in Tableau. The first is if I double-click on the measure that I care about, it will be placed on the Rows Shelf and it will draw a y-axis. I also know that the default mark type, when there’s one measure on the view, is Bar, as you can see in this dropdown.
So we technically already have a bar chart. We’re now just going to break that down by the Sub-Category dimension. Sub-Category was drawing a column for each Sub-Category. So I’m going to drop that onto the Columns Shelf. And then that bar chart was sorted in descending order.
Hopefully that’s review for you. Let’s move on to creating the highlight. The first step is to create a parameter. There’s actually three ways to create this parameter containing the allowable values of each of my 17 sub-categories. But the easiest way to do it is to right-click on the dimension that I want to highlight, hover over Create, and click Parameter.
What this does is it automatically generates the code for a parameter with the correct data type and all of the allowable values. These allowable values match the dimension members within that dimension called Sub-Category. So that’s actually already all correct. I’m going to click OK. That’s all I need.
And the second step is to create a calculated field that gives Tableau instructions for what to do with the allowable value in that Sub-Category Parameter. There’s actually several ways to write this formula. We talked about these on the previous video How to Highlight a Dimension Member in Tableau, if you want a little bit more context on what’s more and less efficient.
But the most elegant way to write this formula is to simply type the name of the original dimension equals the name of the parameter. And I’ll give this a name. I’ll call this my Sub-Category Highlight. And the reason this is most elegant is this is a Boolean formula. Either the dimension member in the Sub-Category dimension matches the allowable value in the Sub-Category Parameter or it does not. There’s only two outcomes, True or False, and there can only be one thing that’s true at a time.
By the way, if I want a reminder of what the allowable value in that parameter is, I can click on anything that is purple within a calculated field and it will show me the current value. So right now, it is Accessories. So in theory if this works properly, this statement will only be true when the Sub-Category dimension member equals Accessories.
Let’s try it out. Going to click OK. If I’m wanting to highlight or color these dimension members by that new highlight, I need to drop that newly created calculated field onto the Color Marks Card. And sure enough, we get one color for True, which is Accessories, and a second color for everything else. That’s great. Good start. There is a critical step, though, to allow your end user to choose what Sub-Category is being highlighted.
We need to make sure we show the parameter control, which you can do by right-clicking on the parameter and clicking Show Parameter Control. We now see this dropdown containing all 17 of the allowable values. If I change what is being– if I change the current value of that parameter, that value Binders has just overwritten the allowable value called Accessories in this Highlight calculated field, therefore changing the outcome to make Binders True and everything else False.
One last thing, these are the default colors. For extra points, you could have remapped some slightly nicer looking colors. For True, I might make that a gold highlight. For False, because it’s not as relevant, maybe make that a gray color, so it kind of fades into the background. Click OK.
And now, regardless of what I click on, that highlight will change. And just as a reminder, you know, we’re just getting some practice with this exercise. But this will work across worksheets now. So now that we’ve gone through those steps of creating the highlight, we could just add that Sub-Category Highlight to the Color Marks Card of any sheet containing the Sub-Category dimension. And that one parameter control would control the highlight throughout all of those worksheets.
This has been Ryan with Playfair Data TV – thanks for watching!
Related video: How to Highlight a Dimension Member in Tableau
Related video: 5 Ways to Make a Bar Chart in Tableau and An Introduction to Aggregation
Related video: An Introduction to Sorting in Tableau
Related video: An Introduction to Tableau Parameters
Related video: Storytelling with Color Tips
- Making Your First Tableau Dashboard (Part 1)
- Making Your First Tableau Dashboard (Part 2)
- An Introduction to Tableau Dashboard Actions
- How to Avoid Highlighting Dashboard Action Selections
- How to Use Tableau Parameter Dashboard Actions
- How to Do Pagination in Tableau
- Tableau Dashboard Element: The Current Versus Comparison Callout
- How to Make a Stock Ticker Gauge in Tableau
- How to Create Performance Indicator Titles in Tableau
- Tableau Dashboard Element: The Global Filters Tab
- Tableau Dashboard Element: The Parameterized Scatter Plot
- 3 Ways to Add a Button to a Tableau Dashboard
- How to Make a Navigation Bar with Buttons in Tableau
- How to Add a Filter in Use Alert to a Tableau Dashboard
- How to Highlight a Dimension Member in Tableau
- Exercise: Highlight a Dimension Member Using a Parameter Control
- How to Make Indicators with Custom Shape Palettes in Tableau
- How to Add a Show/Hide Button to a Tableau Layout Container