How to Make a Custom Color Picker in Tableau Dynamically Change Background and Marks with a Single Click Color is an essential asset to branding, engagement, and storytelling. In this video, you’ll learn how to (1) map custom colors, (2) create a seamless custom-colored background, (3) dynamically change mark colors, (4) add extra emphasis to selections using alt code characters, and last but certainly not least, (5) avoid the dreaded default Tableau highlight!

How to Make a Custom Color Picker in Tableau

Dynamically Change Background and Marks with a Single Click

Color is an essential asset to branding, engagement, and storytelling. In this video, you’ll learn how to (1) map custom colors, (2) create a seamless custom-colored background, (3) dynamically change mark colors, (4) add extra emphasis to selections using alt code characters, and last but certainly not least, (5) avoid the dreaded default Tableau highlight!

Hi, this is Ryan with Playfair Plus, and in this video, I’m going to show you how to make a custom color picker in Tableau. This color picker will dynamically change the entire background color of a dashboard, and/or the marks within worksheets on those dashboards. I’ll also show you how to use alt code characters to give your color selection extra emphasis. And then last but not least, I’m going to show you how to avoid the dreaded highlights in Tableau. I’ve got a new trick for you that I think you’ll find very useful.

By the end of this video, you’ll be able to make something similar to what you see on the screen here. Notice there are three brands to choose from, and as I choose a different brand, the background of the view changes. The selection is got an indication with that star character, and the marks themselves have also changed color. So I choose the third brand. You get that gold color.

So over here in Tableau Desktop, I’m going to start by creating a view, so I can eventually show you that we can change the marks on that view, and tie it to this custom color selector. I should mention before I start to create a view, that I’m using a slightly altered version of the Sample Superstore data set. I went in prior to the video and I replaced the Category column with a column called Brand. So you’re probably used to working with Category. That includes the dimension members of Office Supplies, Furniture, and Technology. I’ve just replaced that with a column called Brand. It includes three different kind of fake brands- Kingfisher, Hummingbird, and Meadowlark.

And this could be tied to any view. I’m going to create a kind of quick spark bar trend view. Sales will be my measure that I care about. I’ll break that down by Region on rows, and then I’ll use continuous month of Order Date on columns. And just to slightly change the aesthetic of this, I’ll change the mark type from line to bar.

Alright, if we were wanting to tie this to the selector, I often like to use a Boolean filter that ties whatever dimension I am trying to filter something on to an equivalent parameter. So let’s say that I wanted this view to be both colored and filtered to a specific brand. The first step for me would be to create a parameter from that dimension.

The easiest way to create a parameter from a dimension is to right click directly on the dimension, hover over Create, and choose Parameter. The advantage to doing it that way, is Tableau has automatically created the parameter with the same data type as the dimension, and it’s automatically populated the list of allowable values with the dimension members from that dimension. So that leaves me with simply giving this a title. I always like to title my parameters with the syntax p. That just helps me find the parameters later on when I’m typing calculated fields. So I’ll call this p. Brand. And I’ll click OK. And now we’ve got both a dimension called Brand, as well as a parameter called p. Brand.

To show you that this is working, I’m going to go ahead and map the colors that I eventually want in my custom color selector. To do that, I’m going to drag Brand to Color. You see that my three different brands are now represented. I can remap those colors by either clicking the Color property on the Marks card, or double clicking any color within the color legend. I will go ahead and give some colors that are more in brand. Hummingbird I’ll give green. Kingfisher I’ll give red, and Meadowlark I’ll give this gold color.

Now that I have mapped those dimension members, Tableau will remember that. So on all my other sheets, including this background image that we’re about to put in, it’s going to remember that those colors are mapped to those specific dimension members. It’s very helpful that it remembers that. I’ll go ahead and click OK. We see the nice new branded colors come in.

But if I were wanting to filter this by just one of those three brands, I could make a Boolean filter, which you can do by just creating a calculated field. Then I’ll call this Brand = p. Brand. And that’s actually the entire formula. So I’ll just type that one more time. Brand = p. Brand.

And this is, in fact, if I click OK, you’ll be able to see this better. But this is a data type of Boolean. I know that because of this t | f symbol next to the calculation that I just created. That means that it only has two outcomes. It’s either True or False.

So if I were to place that onto the Filters shelf, and choose True, we will be left with a single brand, and that brand is going to match whatever the current value of the p. Brand parameter is. We can do a quick quality check by showing that parameter, and making a couple of different selections. If I choose Kingfisher, Kingfisher is now the current value of that brand parameter. That p. Brand parameter feeds this filter that says Brand = p.Brand, so that when I place that on the Filters shelf, we’re left with only Kingfisher. If I were to choose Meadowlark, the same thing would happen. It would change to Meadowlark, and that yellow color is still intact.

Alright, that was just to kind of lay the foundation. We needed that parameter. We needed that calculated field, that filters to just the parameter selection, and we mapped our colors.

Now to get into some uses of this. We’re going to make a background image that’s going to go across the entire dashboard. So I’m going to start a new sheet, and I’ll call this my Background. I changed the mark type to Square, and I place Brand onto Color.

So at this point we see our three colors. Like I mentioned, those colors are intact. Tableau remembered those for us. But we really only want one of these at a time, so we will once again apply that Brand = p. Brand to the Filters shelf. Choose True. Click OK. And then with this one, I make the squares as big as possible. You probably don’t even need to do that. But later on, you can make this fit the entire view so that it fills all the available white space.

Alright. Now to put this into play and show these two things together. I’m going to start a dashboard, and the background itself should be the only tiled object. So Tiled is the default. I’ll place my background onto the view. I don’t need this layout container. I don’t need the title. So there’s our background. I’m now going to float my trend over the top of that background.

And we’re going to make a custom selection. So we don’t need this parameter dropdown. Get rid of that.

We also don’t need the color legend. I think that’s going to become pretty evident with all the different colors on here. Then I just need to center this sheet on the view. One of the advantages to floating objects is when you select them, if you navigate to the Layout pane, you can change both the x dimension, which is in, on the x-axis, and down on the y-axis.

So I’m just going to center this up a little bit. I’m 150 down and 100 in. And then for the width, I’ll do 800 wide, and 600 tall. And just so we kind of know what we’re looking at, maybe I’ll add a floating object that says this is Sales by Region and Month, something like that. Make that a little bit bigger. Probably make it white, because it’s going to be on a colored background. And we’ll call that good.

Alright so now we’ve got a couple of applications of the color. But now for the color selector itself. And this is where I’m going to show you a trick for not highlighting, and also how to add extra emphasis to your selection.

So on a new sheet, I’ll call this my Color Selector. And the first thing I need to do, is change the mark type to Shape. And I’m going to place Brand onto Columns. So that will result, by default, in three columns and three circles. Circle is the default shape. Make these a little bit bigger so you can see them.

Alright, part of the trick to this color selector is instead of using the mark itself as the buttons, we’re going to use labels instead. So the next thing I’m going to do, is drag Brand to Label, and also drag Brand to Color. And so now, you’ll see that those circle shapes are colored properly, based on the mapping that we did in a previous step.

However, the labels could use a little bit of work. They’re not aligned in the center. They also are not the same color as that background shape. We can fix both of those by clicking on the Label property of the Marks card. And for the first one, I’ll click this ellipsis. That opens this word processor where I can customize this a little bit, maybe make this semi bold. Maybe make the text a little bit bigger.

You can always apply hit the Apply button to preview a change. I’ll just bump those down one, and we’ll call that good. For the alignment, that’s a little bit further down. If I change that to Center, now those are center aligned. But really the most important thing that I want to do here, is on the Font dropdown. There’s an option to match the label color to the color of the marks themselves, by clicking this button, Match Mark Color.

When I do that, you’ll see that my labels are now the same color as the shape behind it. And here’s the first step of the trick that we’ll talk about later on, to not highlight those shapes. I’m going to click on the Size property, and increase that all the way to the right, so that the circles are so big that I can’t see them.

If you can see them– so if this were a little bit smaller, you can see that I couldn’t quite make the circle big enough to go off the entire view. Well I’ve got a hack for that too. If you double click directly on the Columns shelf and just type two tick marks, and then hit Enter, now all that does is create an extra column. So it’s got two tick marks per brand. And now those columns are being cut off, and I can no longer see the shapes. They’re still there if I made these smaller, you could see them again. But that just helped alleviate. So the shapes are there, but we’re left– or it appears that we’re left with just the words.

From here, I can clean this up quite a bit. Just maybe get rid of all my headers, labels, lines, can do all that by right clicking. Let me get rid of my column dividers and row dividers. And then lastly, my tooltips. Turn those off as well. So there’s the foundation of my color selector. But another trick I wanted to show you, is how to add emphasis to whatever has been selected with an Alt code character.

Those are called Alt code characters, because you can access a variety of different shapes and characters by holding down the Alt key while you click on a combination of numbers. That’s one way to do it. Or these days, you can just Google Alt code characters for whatever shape you’re looking to find, and you’ll land somewhere like this. If I wanted to use a star, instead of holding down Alt and typing these numbers, I can simply copy that star.

So now that I’ve got the star character, I’m going to jump back here, and I’m going to make a calculated field that says, I’ll call this my Star Label. And I’ll use the Immediate IF function this time. And I’ll say that if the Brand equals the p dot Brand parameter, then I want to display a star character. Notice I wrapped it in quotation marks, because it’s a string. So it needs the quotation marks, comma, two quotation marks, which will just display nothing.

And now I’ve added a little customization. So to talk you through this calculation, the Immediate IF statement looks at this logic. When that logic is true, it displays whatever you type after the first comma. When this logic is false, it displays whatever you type after the second comma. If I click OK and add that newly created Star Label to Label, we should see only one of the three brands get the star. And that should be matching the current value of the parameter. And it is.

Now that it’s there, I can click the Label property, and click the ellipsis to properly align that star, so that it precedes the name of the brand. So I’ll copy the star label. Cut, rather, and then I’ll paste it before the brand. Make sure there’s no extra breaks or anything in here. Click the Apply button to preview the change, and that looks good. Just to make sure that this is working how I expected it to, I’m going to click a couple of different brands. Hummingbird, Kingfisher, and sure enough that’s working.

Couple of very subtle cleanup things I want to do. I noticed that the text was flashing. That has to do with the animation that now comes with default in Tableau. With this selector, I never want to animate it. I just want it to look there all the time. I don’t want that little flash to appear. And fortunately, I can turn that off by just clicking Format in the top navigation. And then choosing Animation, Animations. There it is. Turn that off.

Now when I make a selection, you see it doesn’t flash on the screen. Last thing, if I wanted to change the sort order of these, by default they’re just going in alphabetical order. But I could click Brand on the Columns shelf and choose Sort, and if I chose Manual, I could move these around if I wanted. Maybe I’ll put Kingfisher first, then Hummingbird, then Meadowlark.

So that is my color selector. Now I’m going to hook this up on a dashboard, so that my user can click a brand, and have it automatically change the color of that background. Nice little storytelling and branding technique is what we’re implementing here. So I’ve got my color selector. I’ll hide the title, hide all these legends that came over with it. Make this fit the entire view. Make this a little bit longer. Just kind of aligning this up a little bit.

Put that over here to the right. That seems pretty close. Let’s see how we did. Maybe one pixel down. This is too– too big a text. So I’ll change that. Alright.

So mostly there, we got our whole foundation, all of our pieces. Now we’re going to connect them together. To change the value of that parameter by clicking on this sheet, we’re going to add a parameter dashboard action. So I’ll click Dashboard in the top navigation, then Actions. There are six different types of actions. We’re looking for this one called Change Parameter. And this is our Brand Selection.

And this interface is pretty intuitive. We’re just saying if you select something on the Color Selector sheet, so that’s the source of the action. I want you to target the p. Brand parameter, and send the Brand. So that’s the value that we’re going to pass from the Color Selector sheet to the p. Brand parameter. And that is the entire setup. Does not get an aggregation, because the data type is String. We’re not aggregating the text.

So I’ll click OK. Click OK again. Go to Presentation mode to see how we’re doing so far. If I choose Kingfisher, we were already on there. More on that in a moment. I’m going to show you how to avoid that selection highlight like that.

If I choose Hummingbird, the color changes, and my star moves over to the hummingbird. If I choose Meadowlark, star changes again. Meadowlark gets passed to the Brand parameter, that changes the color throughout. So that’s pretty good.

Might even like this aesthetic of even more emphasis, where those are kind of grayed out in the background. But I’m going to show you a really easy trick to avoid that highlight altogether. So last step in this tutorial, we’re going to add one more dashboard action. So if you click Dashboard and then Actions, the action type this time will be Filter. The source of the action, first let me call this Don’t Highlight, the source of the action is once again the Color Selector sheet.

I want that to run on Select, which is synonymous with click. But here’s the trick to getting this to work. Instead of targeting a sheet that’s on the current dashboard, we’re going to target the Color Selector sheet itself. And then last critical step is, if you choose Show All Values when you clear the selection, you’ll see the next time that I make a selection in my color picker here, that my colors have returned and when I make another selection, there’s a lot going on now.

Not only is the dimension member being passed to the p. Brand parameter, that’s also coloring the marks in my Spark Bar view. It’s coloring the background color to put it fully in brand. It’s moving the star indicator to the current selection, and we don’t have the dreaded Tableau highlights.

This has been Ryan with Playfair Plus – thanks for watching!