Ryan Sleeper
Ryan demonstrates how to use parameters as filters and how to create a user experience that allows you to create a master reset button. This single button will automatically reset all the parameter filters to their original, non-filtered state.
Hi, this is Ryan with Playfair Data TV. And in this video, I’m going to show you how to use parameters as filters, and also how to create a user experience that allows you to create a master reset button. So if you click a single button, it will automatically reset all the parameter filters to their original, non-filtered state. By the end of this video, you’ll be able to make something similar to what you see on the screen here.
This simple dashboard was built with two different worksheets from two different data sets. The callout number came from one data set, the map came from a second data set. There is a single parameter that controls the region being selected on both sheets, even though they’re built with different data sets. So I choose Central, the entire visualization will filter to Central.
And notice there is a Reset button. If I click on that Reset button, that value gets passed back to the parameter filter and everything else has been filtered to its original state. There are several benefits on why you might want to use a parameter as a filter. Most notably, it unlocks a lot of flexibility in the allowable values of that filter. We show you on a different video, here at Playfair Data TV, how to make a entire data source that is just the allowable values for various parameters.
The reason that’s beneficial, is you can create things like custom selector sheets. Not only that, but these parameter filters work across data sources. So you only have to set up a single parameter, and that value gets fed across even multiple data sets. And I also find that these parameter filters are a little bit easier to manage, and it’s a little bit more understandable and intuitive on what the result of the parameter filter is going to be. Lastly, you might even get a little efficiency boost, because we’re gonna convert the filters into Boolean statements which are a little bit easier for Tableau to process.
Obviously, I always talk about how parameters are my Swiss army knife. So you can use this with any example, but I’m going to just build a couple of different sheets. First, with the Sample – Superstore dataset, I’ll make a map. And I’ll do that by dragging State– actually, I’ll just double-click State. But then I’ll convert this into a field map by changing the Mark type from Circle to Map, and then I will drag Region onto Color. So, that’s our first example.
And then just to show you that this works across data sources, I’ve connected to this very simple secondary data source, just to show you what the data is within there. I’ve got one dimension– I did put a little curveball in here, and I called it Territory instead of Region. That’s one of the benefits of using this technique, is the names of the fields don’t have to be called the same thing. And then I’ve got a secondary measure, could be any measure. It happens to be unique orders from the sample data set, but one dimension, one measure.
I’m going to create a second sheet, called Call-Out number, by just dragging my secondary measure to the Text property. Right now, that is the sum of all unique orders in the data set. Call-out numbers are typically a little bit larger, so I’ll bump up the font size, click Apply, maybe give this a title. We’ll call it my custom measure, just pretending that I’m bringing in something from another data set. And maybe I’ll center that up. All right, so I’ve got two different sheets.
The first thing I need to do if I’m going to filter the marks on the View by a parameter value, well, I need a parameter. To create a parameter, I personally like to right-click in any blank space on the Data pane and choose Create Parameter. But I’m going to show you a shortcut, where if you know the allowable values that you want to use right out of the gate, you can right-click directly on the dimension that you want to create that parameter from, hover over Create, and choose Parameter.
And this has a few advantages, most notably, it populates the allowable values with the dimension members from that dimension that you’ve created it from. It also gives it a relatively intuitive name, it just adds parameter to the end of the dimension name. And I know that I’ve got the correct data type, which is String, in this case. So, I clicked on Region because I’m making my first parameter filter out of the Region dimension members. Eventually, I’m going to let my user choose from any of the four regions.
But in order to also have the value of All, or Reset– you can name this whatever you’d like. For the purposes of this example, I’m going to name it Reset. You can just add an allowable value within this parameter, called Reset. So, my allowable values are now the four dimension members from within that dimension. And then I added a custom one just manually, I just clicked on the list of values and typed reset. That is the entire parameter. Now if I click OK, I can filter these marks based on the value of that parameter.
I will show the parameter, so we can follow along and see what this is doing. Let’s say that, by default, I want Tableau to show everything. So instead of a single allowable value being selected, I’ll choose Reset. And then to convert that into a filter, I could set up a calculated field that says Region equals Region Parameter. But to make this a little bit more elegant and keep my number of calculated fields down, I will drag the Region dimension to the Filters shelf. If I navigate to that condition tab and choose this by formula radio button, this is where I can put that logic that would have been in the calculated field.
So the entire formula is Region equals Region Parameter, but then to also account for my custom, or manually, added Reset option– remember, when that is selected, I want Tableau to show all of the four regions on the View. So the logic would be, or my Region Parameter equals All. So either it equals one of those individual dimension members, or it equals Reset, or whatever you had named that. So, that is the entire formula. I’m actually going to copy that logic, because I might need that in a future step, and click the OK button.
If I did that correctly– I don’t see anything change yet. And I do not yet. So that is because that little bit of logic I put in there at the end, if this equals Reset, basically, it’s going to show everything on the View. If I choose an individual region, however, it’s going to filter to that View. So, that’s the first way to use a parameter as a filter. But one of the advantages that I mentioned, is you can use that single parameter across data sets. So, let’s go work on our Call-Out Number sheet.
Remember, this was built with a completely different data set. We don’t have Region in this data set, but we do have Territory. And if I describe that field, I can see that the dimension members are the exact same as the Region dimension in the Sample – Superstore dataset. So, I can make a very similar filter. I can drag Territory to the Filters shelf, navigate to the Condition tab– I copied this formula, so I can just paste it into the Condition, but it doesn’t recognize the Region field.
Remember, that name has been changed. It’s now Territory, so if I type Territory instead of Region, this should recognize it as a field. It turns orange, which means it did recognize it. And if I click OK, we have a Territory filter now, instead of a Region filter. I will show that parameter so that we can see the allowable values. And we didn’t see that number change, it’s because, again, it’s showing everything currently. But if I choose a different region, now that is being filtered. So the key there, is this is being driven across two sheets, multiple data sets, but it’s being driven by a single parameter.
And I’m just showing you a very quick example, but you can imagine, you can roll this out across as many worksheets as you would like. And even as many data sets as you would like. So, it becomes very powerful. We’re just sticking with a very simple example for now. I also should point out, I’m aware that Region, because it’s in the sample data set, you could use a filter and apply that filter across worksheets. But the benefit to using this parameter version, is it could be any field. Those fields could be called whatever you would like, and you can name those allowable values whatever you like. So, yes, we’re using a familiar dimension.
And there are easier ways to do filtering with that dimension, but this parameter version, this tactic that I’m showing you is a lot more flexible and scalable. There’s other advantages to it. All right, so we’ve got our two sheets. Let me go ahead and reset this and put those on a view, and then we will build out our Reset button. So I’m going to put my map on the View first, maybe I’ll make the Call-Out Number floating and put it towards the top. Hide some of these headers, just clean this up a little bit, fit the Entire View. Maybe for this one, I’ll get rid of the shading in the background so that it’s seamless, how it looks.
I never liked these default tooltips, so I’ll get rid of that. Maybe move that to the top. All right, so very simple dashboard, just to show you that this is intact and working together. We’ve got the parameters being shown, and the allowable values can be selected and filtering here. But the new piece that I’m going to show you now, is how to pass this reset value via a button, so that the user has one-click access to just resetting the whole View. This requires a third sheet that I’ll just call, Button.
There’s lots of different ways to customize this button, but to keep this simple for the video, I will make a very quick button by changing the Mark type to Square. And the key to getting this tactic to go, is I need to make a calculated field in either of my data sets, that the entire formula will just be the name of the value that I’m using to reset that button. So because I called it Reset, the entire formula will be, quote, “Reset.” And the reason I put that in quotes, is the data type for this reset button is Text. My parameter is also a data type of Text and eventually we’re going to pass that word, Reset, to the parameter, which will then reset both of my sheets.
So, that’s the entire formula. I’ll click OK, I will add that as my label, and now that there’s something on the Marks card, we see the shape appear. I will also make that shape a lot bigger, just format this a little bit. So I made the size as big as possible, maybe I’ll center the label. You could see that animating– I want to turn that off, because I don’t want that label to fade in and out. You can turn off an animation for a sheet by navigating to Format, Animations, and just clicking that Off button. But we’ll call that good enough for this button.
Now if I go back to my dashboard and add that button to the View– maybe I’ll put it over here on the right side near my original parameter, just so you can see that this is working. So everything is on the View, but to link these two things together, or all the pieces on this dashboard together, I need to add a Parameter Action. Which you can do by navigating to Dashboard in the top navigation, and choosing Actions. And if I click this Add Action button, I can change the parameter value, and this is relatively intuitive.
I’ll call this my Reset Button, I want it to activate on only the Button sheet. I’ll have it run on Select which is synonymous with click. I am targeting the Region Parameter, and I am passing the Reset Value. This is why it was so important to set that up as a calculated field, because now that’s available to me as an option on what value I want to pass to that Region Parameter. I’ll go ahead and click OK, click OK again, and we can test out how we did here.
So now if I choose an individual region, both the map and the call-out number get filtered to that region. And if I click on the Reset button, the reset value is passed to the reset parameter. Because we added some filter logic that said, the Region dimension could equal either whatever is selected in this parameter, or the value of reset. Because it is now reset, everything is being shown on the View.
I’m gonna show you one last trick that I think is going to be a lifesaver for you, that is a very nice functionality. Again, I showed you a very simple example where it’s being applied to just two sheets. You could apply this to 50 sheets, you could apply this across an entire workbook that has 10 dashboards. It’s really infinite scalability here. But one thing that I don’t love about this user experience, is notice my Reset button has a black border around it, showing it’s been selected. In order to use that again, I have to deactivate it by clicking on it, and then click on it again.
Let’s see– if I click South, I have to deactivate it first and then click it again, and it works. Well, I have a very nice trick to get around that. I’m going to navigate to that sheet and set up a second parameter by right-clicking it in any blank space, choose Create Parameter, and I’ll call this my, don’t highlight parameter. The data type is going to be Boolean, because there’s just going to be two outcomes. And what we’re doing, is we’re just going to pass a value, could be anything, but to keep this as elegant as possible, I’m just going to pass a Boolean value– either true or false. So, the data type is Boolean.
I’ll click OK, that’s going to do very little on its own. So I’m going to create this calculated field that’s called, Don’t Highlight value. And we’re going to set up a very simple formula that says, IF Don’t Highlight equals False, then show True, otherwise, show False. And I can put this in the Related Content below the video, but we’re just faking Tableau out. We’re going to send a value via parameter action and when we do that, it’s going to automatically deselect the button for us. So I will click OK to close the calculation.
That value does need to be somewhere on the View. I will add it to the Detail property of the Marks card, and go back to my dashboard. And to get this to automatically deselect the Reset button, we’ll need two dashboard actions. The first will be a parameter action, which I’ll add by clicking Dashboard and Actions. And I’ll choose Add Action, this is a change parameter action. And I’ll call this my automatic deselect parameter. And we want it to run when the button is selected. We’re targeting the don’t highlight parameter, and we’re passing the don’t highlight value.
This won’t get aggregated, because it’s a data type of Boolean. You don’t aggregate Booleans. So, that is the entire parameter. I’ll click OK. The second action is a little bit of a tricky way to fake out Tableau, where we’re going to add a filter. We do want this to run when the button is clicked, but we’re going to target the Button sheet. That’s what’s new and, maybe, a little bit different than what you’re used to doing So by default, Dashboard Actions are telling you to choose a sheet within that dashboard.
I’ve changed that dropdown to target the original Button sheet. And then, lastly– very important, we want to make sure this radio button is selected to Show All Values. And now if I click OK, click OK again, let’s see how we did. I’m going to go to Presentation mode, I will choose a different region. So I’ve gone to East, now if I click the Reset button not only did it reset the whole View, but notice that the sheet has now been selected. So I can, with just a couple more clicks, navigate to a different region. So I click Central, I no longer have to select the Reset button. If I choose it again, we’re back to the original View. This has been Ryan with Playfair Data TV. Thanks for watching.