1. Parameters
We’re going to create a Parameter so that users can specify the top number of stations they want to see on this map. So if we go to the Data Pane, we can create a Parameter right under the Calculated Field option.
For name, we’ll call it Top N Stations. We want this to be an integer because it wouldn’t make sense to show the top 12.5 stations, for example. But note, there are a lot of options from Float to Date.
We can set a current value, meaning the default value it’s set at when the workbook is opened. Let’s set at 10. For allowable values, we’ll use a range. There’s about 600 stations, so let’s make the range 0 to 100. For step size, I’ll make it 5.
So now, we see it’s in it’s own section down here in the Data pane. Let’s right click on it and “Show Parameter”. The legend shows up here and you can see that we can take steps up or down. Remember, I set the step size at 5 with an initial value of 10 so it’s skipping to multiples of 5, but you can customize it to your liking!
This parameter is not connected to the viz - meaning nothing is changing in the viz. There are a couple ways to connect it.
We’ll first connect it to a filter. Remember, I want to look at the top performing stations in terms of number of trips. To do that, I’ll drag FROM STATION NAME to the filter shelf. In this popup, I’ll select TOP. Again, we’re looking at top, but you could also do bottom to see the low performers. Instead of setting a number here, I’m going to connect it to the parameter we just created. We’ll be doing it by the count of Trips.
Once I say ok to this, notice instantly all the other dots disappear. That’s because the current value is set as 10. I can change the values here to increase the parameter value. Here’s my top 30 stations for example.
Another cool way to use a parameter is through a calculated field.
Here we have a bar chart showing the number of rides for each station in descending order. We can add the parameter to the sheet. What we want is for the bar chart to dynamically change colors when we change the parameter.
To do this, let’s create a calculated field called Top Stations by Rides. We’ll call the rank function and then we’ll call the count function to count the rows of Trips. This is similar to when we add a Rank Quick Table Calculation on Trips Count.
And then we’ll say less than or equal to our parameter, TOP N Stations.
Let’s break this down. If TOP N stations is set at 10, all stations that have a rank number of 10 or less will be TRUE. While all the stations that have a rank number of more than 10 will return false. This will change depending on what Top N Stations is set on.
In the datapane, we see that the calculated field has a TF next to it, because it returns True or False. While another calculated field we made earlier, Age, has a hash sign next to it because it returns an age, which is a number.
I’ll drag this new calculated field to Color and I’ll also Show the parameter we made. We can toggle our parameter and the graph dynamically changes color. If we hover the bars, we see our calculated field in the works. The top bars are listed as true, while the others are listed as false.
We can easily edit the parameter here if we want to change the step size.
Ok time for you to give it a try!
2. Let's practice!