Tableau has some incredibly powerful tools for interacting with your data. This 4-part series contains a number of tips and tricks for leveraging those tools to build business dashboards that are more flexible, more engaging, more powerful, and generally, just a lot more fun to use. This is part 3 of the series and covers how to use "Scroll" buttons to limit the results in your view and allowing your users to scroll through "pages" of results. Check out the Resources below for a link to the dashboard referenced in this blog post, and to a short video demonstrating all of the steps in this post.
Resources:
Often times we end up with dimensions that need to be visualized in our dashboards, but that have thousands of unique values. Rendering all of these marks in Tableau can have significant impacts on your dashboard's performance. A common practice is to limit the results to the top "N". But what if users need to see the next set of records, or the set after that. In this post we will discuss how to use "Scroll" buttons that allow your users to view one set of records at a time and use buttons to move to the next set.
First, we are going to create two worksheets, one for the left (or decrease) button, and one for the right (or increase) button.
Create a new worksheet named "Range Decrease"
Create a calculated field called 0 with just a 0 in the body of the calculation
Create a calculated field called 1 with just a 1 in the body of the calculation
Drag both the 0 and 1 fields to Detail
Change the mark type to "Shape"
Click on Shape and select the left facing filled arrow â—„
Create a new worksheet named "Range Increase"
Drag both the 0 and 1 fields to Detail
Change the mark type to "Shape"
Click on Shape and select the left facing filled arrow â–º
Next, we want to add these worksheets to our dashboard
Drag a horizontal container on to the dashboard
Drag both worksheets into the container
Hide the titles (right click and select "Hide Titles"
Position the container below the worksheet you want to control and resize it
Now, we want to create a parameter that we can use to set a "range" of records to include in the view
Create a parameter called "Lower Range"
Set the Data Type to Integer
Set the Current Value to 1
Now we are going to create our filter
Go to the sheet that you want to control (In this example it is the "Metric by Manufacturer" worksheet)
Create a calculated field called "Range Filter"
INDEX()>=[Lower Range] and INDEX()<[Lower Range]+10
This will display 10 records at a time. If you want to show more/less records you can adjust the 10 value at the end of the calculation. You can also use a parameter if you want to make the number of records displayed dynamic
Drag the "Range Filter" field to the filter shelf and filter on True
When we click on a button we want it to adjust the Lower Range parameter, which will adjust the "range" of records that are displayed. When we click on the left arrow we want to decrease the range by 10. When we click on the right arrow we want to increase the range by 10. But we also want to make sure that the parameter value doesn't go any lower than 1, or any higher than the number of values we have in our dimension, as no records will be displayed. We essentially want to "turn off" the buttons when they hit their upper or lower limit. We'll start with our left (or decrease) button.
Go to the "Range Decrease" worksheet
Create a calculated field to test if the range is already at its lower limit and call it "Lower Range Limit"
[Lower Range]=1
Drag the "Lower Range Limit" field to color and update the color for the True and False values
Create a calculated field that will be passed to the parameter called "Range - Decrease"
IF [Lower Range Limit] THEN 1 ELSE [Lower Range]-10 END
Drag the "Range - Decrease" field to Detail
Now we'll repeat for the "Range Increase" worksheet but with some modifications to the calculations.
Go to the "Range Increase" worksheet
Create a calculated field to test if the range is already at its upper limit and call it "Upper Range Limit"
[Lower Range]+10>={ FIXED : COUNTD([Manufacturer])}
Drag the "Upper Range Limit" field to color and update the color for the True and False values
Create a calculated field that will be passed to the parameter called "Range - Increase"
IF [Upper Range Limit] THEN [Lower Range] ELSE [Lower Range]+10 END
Drag the "Range - Increase" field to Detail
Next, we want to add a Parameter Action for each of our buttons to pass the Increase/Decrease values to our parameter
Click on Dashboard > Actions
Click "Add Action"
Select "Change Parameter"
Give the parameter a name
Under Source Sheets, select the "Range - Decrease" worksheet
Choose "Select" under the "Run Action On" options
Under "Target Parameter", select the "Lower Range" parameter
Under "Field", select the "Range - Decrease" field
Your final parameter action should look like this
Next you'll want to repeat the steps above for the "Range - Increase" button. Note the differences below
Under Source Sheets, select the "Range - Increase" worksheet
Under "Field", select the "Range - Increase" field
Your final parameter action should look like this
Now when you click on a button you'll see that the range of records adjusts. However, each time you navigate to a new set of records the axis automatically adjusts. We still want to size all of the marks relative to the highest value, as it would be if all of the marks were present in the view. We can't fix the axis because it can change depending on what metric is selected and what filters are applied. Instead we are going to use a reference line to artificially fix the axis based on the highest value.
Go to the "Metric by Manufacturer" worksheet
Create a calculated field called "Range Ref Line"
WINDOW_MAX([Metric Calc])
Drag the "Range Ref Line" field to Detail
Add a reference line
In the left window, click on Analytics
Click on Reference Line and drag it to "Table"
Next to Value, select "Range Ref Line" and set aggregation to Minimum
Set Label to "None"
Set Tooltip to "None"
Set all Formatting to "None
Your Reference Line options should look like this
Now as you scroll through the records, the axis remains fixed. However, you may notice that you need to click on a button multiple times to complete the scroll action. Once a mark is selected by clicking on it, you need to click again to deselect it, and then again to drive another action. We can prevent this by using the Filter Action method we had outlined in Part 2 of this series. Use the process outlined in that post to add a Filter Action to both the "Range Decrease" and "Range Increase" worksheets. For convenience, here is a quick review of that process
Click on Dashboard > Actions
Click "Add Action"
Select "Filter
Give the Action a name
Under Source Sheets select the "Range Decrease" worksheet
Under Target Sheets click on the drop-down and select the "Range Decrease" worksheet (do not select it from the default display list)
Choose "Select" under the "Run Action On" options
Under "Clearing Selection Will" select "Show All Values"
Under "Target Filters" choose "Selected Fields"
Click the "Add Filter" button
Under the "Source" Field choose 0
Under the "Target" Field choose 1
Click OK
Repeat this process for the "Range Increase" worksheet
That is it for today. Keep an eye on our blog for Part 4 of the series which will cover how to add an instruction "overlay". If you have any questions or comments on these tips, please let us know at info@cleartelligence.com.
Comments