Learn how to use parameters in Tableau to dynamically control top-N filters and enhance interactivity within your dashboards. This article walks through building a custom slider that allows users to adjust the number of top-performing subcategories displayed based on sales.
Key Insights
- Filters in Tableau cannot be used to dynamically adjust the number of items shown (e.g., top 5 vs. top 10); parameters are required to create this type of user-driven flexibility.
- Creating a parameter, such as "Top Nth," allows for the input of a custom value (e.g., 5, 10, or 17) and can be connected to a filter to control which top categories are displayed based on sales data.
- Noble Desktop’s tutorial demonstrates how to integrate a parameter with a visualization, using sliders or input boxes to adjust values during live presentations or within dashboards published to Tableau Public.
Note: These materials offer prospective students a preview of how our classes are structured. Students enrolled in this course will receive access to the full set of materials, including video lectures, project-based assignments, and instructor feedback.
We're going to create another parameter just to show you another way that it's useful. This is definitely going to be an example of something you cannot do with a filter. Whereas you can sort of see how you might be able to do what I just did with a filter, this you will not be able to do with a filter.
And yet, we're going to assign the parameter to control a filter. So creating a user controllable top filter. The goal here is I want to be able to choose top 5 or top 10 categories, subcategories by sales.
So I'm going to show you how you would do it as a filter, and then I'll show you what the problem is. And then we'll create a parameter that'll make this a lot easier. So parameters can be used to control filters as well as calculations.
This allows you to add user editable features to properties that are normally not editable. So I'm going to create a worksheet. And in this example, we're going to create a bar chart using sales and subcategory.
All right, so I'm going to do that. Create a new sheet. I'm going to take sales and I'm going to move it over into columns.
I'm going to take subcategory and move that into rows. I think I'd like to see a column. So I'm going to flip this and I'm going to make this entire view.
So let me show you what we're trying to do with a filter. We want to get the top five subcategories. So I'm going to go over to subcategory.
I'm going to drag it over to filter. The box opens. And I'm going to choose top.
And what I would like to do is see the top by field top five. I'll enter a value. Top five sales by sum.
I'll click OK. I am now seeing the top five sales by sum. All right, let me make this a little more interesting.
I'm going to take sales. I'm going to move it into color. And I'm going to add labels.
I want to increase the size of the labels. I can, since it's top five. I'm not limited to this size.
Let's do 18 maybe. Yeah, because it's never going to go beyond top five. So I don't have to worry about the numbers being too big.
All right, cool. When you create a filter, the thing you always have to remember is the filter by default does not display anywhere. You have to turn it on.
If I click the drop down here, I actually want to show the filter. Right now it's not visible. I want to show the filter.
Why is this? All right, I'm pretending I'm confused. So how do I filter for something other than five? I would like to do the top maybe seven, top eight. They're all checked.
But there's only five here. What happens if I uncheck what? Wait, chairs is a top five. It's actually like the second highest.
If I uncheck it, it just gets replaced. No, this doesn't work. All right, let me click the drop down here.
Single value drop down. No, no, no, no, no, no. That's not single value slider.
No, no, that's that. If it's all, it shows me five. And then I can, okay, so this is not going to work.
I want to, I know I can get the top five, but I would like to be able to change this. So I can get the top seven, top eight, top 10. I want to be able to use a slider that does this.
You cannot do this with a filter. You would have to use a parameter. All right, so this is not working.
And I think I've tried the options here to get it to work. Multiple values drop down. No, they just show me everything.
And then what am I going to select? These are not necessarily the top five. They just let me choose anything. Okay, I'm going to cancel this.
And I'm going to take out this filter. I'm going to hide the card. This is not working.
So what I need to do is I need to create a parameter. When I had the opportunity to choose a number, right underneath it was the option to create a parameter. That's what I want to choose.
And so this is pretty simple to do. And it's pretty intuitive. When you go through the process, you're going to fill in the information that you have here.
Just like you would normally fill this out based on what you think should happen. So I'm going to go over to subcategory. I'm going to choose edit filter.
Instead of entering a number that's hard-coded, I'm going to click the drop down here, and I'm going to create a parameter. And then I'm going to call this parameter top nth, as in the top five, top eight, top 10, top whatever, top three. So five is the display format.
The current value is five. That's what I want. The minimum value is one.
I only have 17 categories. So I'm going to go over here and type 17. To explain what step size is, step size is if you have values, let's say from one to 100, you may want to increment.
You may want them to increment by 10. So you can make the step size 10. So let me just check to see if the settings are what I think they should be.
Yep, it's basically what I thought it should be. I'm going to click OK, and I'm going to click OK. And parameters by themselves don't do anything.
They are now connected to the filter, and they don't display automatically, just like the filters don't display automatically. You have to show them. So you'll click the drop down here and you'll choose show parameter.
I'll choose show parameter. My default value is five. And so now I want to increase this to show the top maybe seven.
These are the top seven. How about top 10? These are the top 10. I will never go beyond 17 because I set that as my limit.
But now I'm able to use this to filter for whatever amount I want to see. Top five to top 10. All right, so I'm using a slider control.
I could use a type in control. Maybe I would like to type this in. I'll go over here and then now I can go and type in here.
I'll say give me the top five. OK, give me the top seven. And this gives me a little more flexibility.
I'm running my presentation. So I tell someone these are the top seven. Could you show me the top five? I'll go here and say, well, here are the top five.
How about the top 10? I probably should increase the size of the font down below. So that's something I can do. So I can actually see this or maybe I'll go to labels and I'll choose subcategory and I'll bring the label up on top.
Let me bring in sales as well. OK, so now I'll do my presentation. Could you show me the top 10? Yeah, these are the top 10.
How about the top three? These are the top three. OK, so that's another custom control. It's a fancy feature that you can add to your dashboard.
And just as I'm using it here in the presentation view, you can use it on a dashboard. Even like the dashboard I shared with you earlier today that's available on Tableau Public. All right, so that's that exercise.
And again, it's another specific example that should give you ideas about what you might do for your presentation. You may not necessarily want to do exactly what I did. Finalizing the filter.
We did this already. This is just one way of doing it. It's a horizontal slider.
And currently this is showing the top 12. Here they're calling it the limiter. We created a parameter.