Ryan Sleeper
Ryan shows you his favorite approach for highlighting specific marks using a parameter control and, optionally, parameter actions. This highlight effect works across multiple worksheets at the same time, even if the worksheet is not on the current view!
Hi, this is Ryan with Playfair Data TV. And in this video, I’m going to show you how to highlight a dimension member throughout a dashboard. I’m not just talking about clicking on a color legend to highlight a dimension member. This is a much more permanent method for doing so. We’re also going to talk about some better and worse ways to write calculations so that they process as efficiently as possible.
Highlighting a dimension member throughout a dashboard is one of my favorite techniques for helping orient the user to what is most relevant to them. To give you an example of what we’re going to do, take a look at this Tableau Public visualization that looks at Major League Soccer standings. This was a couple of years ago.
The point is the end user right away gets to choose who their favorite team is. And then once they make a selection, that selection will be highlighted throughout the visualization. So they can see how their favorite team is performing in context of everybody else.
Let me switch this to my second favorite team, Orlando City, to show you how that changes. So as you can see, not only does the filter change their record on the left side here. And this running total that’s telling you how many points they’ve earned that season are adding up. It also highlighted them on all of these dot plots. And that’s what I’m going to show you how to do.
I’m going to jump over here to Tableau Desktop. And as I mentioned, we’re going to talk a little bit about formulas as well in this video. But regardless of which approach you take to writing the calculated field, the first step is to create a parameter out of what you want to highlight. So in my case, we’re going to look at a few charts that use the Region dimension.
There’s a couple ways to create this parameter. If I want to allow my end user to eventually choose from any of the four dimension members within the Region dimension, I could right-click anywhere on the Data pane and click Create Parameter. Because they will be choosing from the four directions, which are words, the data type would be String. I would then click the list radio button and type out those options, which are East, West, South, et cetera.
But I’m going to show you an easier way to create a parameter. It’s a little bit of a shortcut. If you want to create a parameter containing the allowable values from a specific dimension– actually, I’ll show you two shortcuts. The first is starting the way that we already did, if I click String, List, I could choose Add from Field, and click the Region dimension. It automatically populates option one.
Even faster though, this is the shortcut I wanted to share with you. If you right-click directly on the dimension you want to create that parameter from, hover over Create, and click Parameter from there, Tableau will automatically create the parameter for you. It already has the correct data type. It already has the list of allowable values populated. So even faster. So I’ll stick with that method and click OK.
So that’s step one, regardless of what formula you choose to write after this. Next thing we need is a calculated field. I’m going to go in order. First of all, I’ll give this a name and call it Highlight. And I’m going to go in order from kind of the least efficient way to write this formula. But also, it has advantages.
One of the advantages I like with the less efficient formula sometimes is that it helps my audience, if they’re a Desktop user, see what’s going on with that formula. It’s a lot more intuitive because there’s more code kind of explaining what’s happening. That’s the one advantage. But we’re going to work our way through and make it more and more efficient. And when I say efficient, I’m talking in terms of how quickly things process in Tableau.
But first way to write this is to say– is to write an IF-THEN statement. So I could say, if the Region Parameter equals the Region dimension, then you can name this whatever you want. We’ll just say then Highlight. What this is going to do– remember, these calculated fields by default will run the logic at the viz level of detail. The viz level of detail in this case is Region.
So it’s going to look at each one of these four regions. It’s going to see if it equals the current allowable value in the Region Parameter. That could only be true for one out of these four. And when that is the case, it will get a special distinction as the highlight. Everything else in this case would be just called ‘Null’ because we haven’t specified an ELSE statement to tell Tableau how to handle the scenario when the region does not match the Region Parameter.
Let’s take a look at how we did. I’ll click OK. And if I were wanting to color these by this newly created Highlight calculated field, I would just drag it to the Color Marks Card. And sure enough, we have a color legend now, one color for when the dimension member matches the parameter value, a second color for everything else. So that’s option one.
If I now show the parameter control, if I choose a different allowable value from this parameter, that value will populate the Highlight calculated field, which changes the outcome. And now East is being highlighted instead of the first allowable value, which was Central. I’m going to edit that Highlight calculated field and show you a slightly more efficient way to write this formula.
Because there are only two outcomes, you’re either being highlighted or you are not, you could use the Immediate IF statement. And that would start with the letters IIF, open parentheses, whatever your criterion is, followed by a comma. What comes after that first comma is the outcome when this criterion is true.
And I’ve mentioned this several times now. But if you click on IIF, the Immediate IF statement, or anything that’s blue rather within a calculated field, it will open this little fly-out where it gives you a definition of what that function or aggregation is doing, as well as an example of how to use it in the syntax.
So first is the criterion, comma. What comes next is the outcome when that criterion is true. What comes next is the outcome when it is false. So we’ll just call it ‘Other’. I’m essentially changing the alias from ‘Null’ to ‘Other’. I’ll click Apply to preview that change.
We do see a different color. That’s simply because we had a dimension member change. It was called ‘Null’. Now it’s called ‘Other’. So it’s getting a third color. But you can see that that formula worked the exact same way as the first IF-THEN statement. If I were to make another selection, it will run through that logic, change the highlight.
A third option. This is the most efficient way possible to write this. Because this only contains two outcomes, we can actually convert this to simply a Boolean formula, which would just be only the criterion. I’ve stripped out all the other code. This will result in either ‘True’ or ‘False’. I’ll click Apply.
I’m going to point out two things. First, note our highlight calculated field over here got a different icon because the data type changed. It’s now a Boolean– only those two outcomes, True or False. We also see two new colors on the color legend over here. Again, that’s because we just changed the names of those dimension members. By default, Tableau is mapping the color to a specific dimension member. And we just keep changing the names of those outcomes. It’s now changed from ‘Highlight’ and ‘Other’ to ‘True’ and ‘False’.
This is the most efficient approach with this highlight technique. The only drawback is it changed the name of our aliases. But as of Tableau 2019.3, you can actually edit those aliases on the Booleans just by right-clicking on them within that color legend. Click Edit Alias. And you can change this to whatever you want. So if I wanted to change it back to ‘Highlight’ for ‘True’ and edit the alias for ‘False’ and change that back to ‘Other’, I could do so. And again, this highlighting technique is still intact.
So that’s one of my favorite ways to highlight and orient my user. But the real beauty of it is now that we’ve gone through those steps to create the parameter and then the calculated field that determines if the dimension members match the value in the parameter, you can roll this out across several sheets.
So I’ve just gone ahead and put together a couple sheets here before starting the recording. If I were to drop this Highlight onto the Color Marks Card– and actually, let’s change these colors a little bit. Those are kind of clashing for me. We’ll do a ‘Highlight’ in yellow and ‘Other’ in gray. Click OK. That looks much nicer.
But the beauty of it is not only will that one parameter control– so if I were to show this parameter control, this will change what’s being highlighted across the worksheets. That’s one advantage. The other advantage is that when I remap those colors, those will also stick. So if I go back to my scatter plot, notice it changed from that kind of greenish and blue tints to the yellow and the gray on this sheet as well. I also changed the value to East. East is being highlighted on the view.
I’ll do this on one more sheet. Just drop Highlight on Color. And to show you that these are all working together in unison, I’ll throw together a quick dashboard containing each of these values, or each of these highlights, so Scatter Plot on top. I’ll put Sales Bar Chart on bottom, Profit Ratio on the bottom-right.
Get rid of that. Maybe I’ll throw a Blank object here just because scatter plots are– it’s best practice to make those square whenever possible. And then we don’t need this legend. And I will float this to get the spacing back. I’ll just drop this here.
So one parameter control– one of the nice things about parameters is they work across sheets. Each of those sheets contains that calculated field called Highlight. And when I change a selection from East to South, for example, it will populate the calculated field for Highlight. It recolors all three charts at the same time.
One more quick note. You can also now use this with parameter actions as of Tableau 2019.2. So another option if you don’t like this kind of clunky dropdown menu is you could set up a control sheet. So I will drag Region to Text.
And just to format this a little bit, I’ll put Region on the Rows Shelf. Give me a nice vertical orientation. I will deselect Show Header because those names were repetitive. And I’m not going to clean this up too much because I’m just trying to share the spirit of what this will do. But this will be my control sheet. I’ll go back to my highlight dashboard and add that to the view. Fit the entire view.
All right, we’ll call that good enough. And from here, I’m going to add a dashboard action by clicking Dashboard on the top navigation, click Actions, Add Action. And we are changing a parameter value. We’re going to say if you click on the Control Sheet, we want you to overwrite the parameter called Region Parameter.
And it will be– it will overwrite the Region field. Note there is no aggregation because the data type is String. So that is exactly what I want so far. You could give this a nicer name if you want to. I’ll call it Region Highlight. Click OK. Click OK again.
And now, it’s set to South. But if I were to click on Central, it overwrites the value in that parameter. The value in that parameter feeds the value in the calculated field called Highlight. That Highlight calculated field then feeds the Color Marks Card for all three of these charts. So it overwrites it. And it changes the highlight. It’s an even more elegant way to highlight a dimension member throughout a dashboard in Tableau.
This has been Ryan with Playfair Data TV – thanks for watching!