Have you ever wondered how to compare a proportion of your data visually against a total? There are a couple of different ways to do so. These methods discussed below are called proportional brushing. You can accomplish a visual comparison with calculated fields or with Set Actions .
Both methods are displayed in my Tableau Public dashboard here.
Calculated Fields Method
In the first example I show the Total sales by month by the most current year. When you select the Sub-Category from a filter a new line will display below the Total sales line as shown below;
This new line will display the total sales for the Sub-Category you select in the filter.
In order to create this view, I had to make a couple of different calculated fields for this worksheet;
Year
Year([Order Date])
Month
Month([Order Date])
Fixed Total Sales
{ Fixed [Year],[Month]: Sum(Sales) }
I put Year on the Filters marks card and checked the box for the most current year.
I put Month on the Columns shelf and made sure it was the Discrete month format.
I selected the Sales and Fixed Total Sales values and then moved the Measure Values pill to the Rows shelf.
I selected Line chart from the Marks Type drop-down.
I dragged Measure Names over to the Color Marks card.
I put Sub-category on the Filters Marks card.
I also changed the colors of the lines, removed the grid lines, etc.
The final worksheet should appear as below;
Now, when you select a Sub-Category from the filter, this category will display below the Fixed Total Sales line.
Set Actions Method
In the below chart I display a proportion of the data based on a Set I created with the Sub-category.
I put Sales on the Columns shelf.
I placed Segment and Category on the Rows shelf.
I put Sales on the Label Marks card.
I dragged Sub-Category on the Detail Marks card.
I right-clicked on Sub-category and selected Create > Set.
I selected Accessories in the Create Set pop-up menu and then clicked OK.
I then moved this set to the Color Marks card.
I selected a light grey for the Out and left blue for the In.
On the Sales Label I selected Percent of Total under the Quick Table calculation. I then selected Compute Using > Table Across for this metric.
The worksheet should appear as below;
Then I added this worksheet to the Dashboard.
I created a separate worksheet for buttons for the Subcategory. I used a min calculation to make these buttons. I used the method in this article here.
I then selected the Dashboard actions menu to add a Set Action.
On the Actions pop-up menu I selected Change Set Values from the Add Action drop-down.
I selected the Subcategory worksheet since this is the button worksheet for the chart. I selected the Sub-Category set from the Target Set drop-down.
I selected Assign the Values to the set under Running the action will menu.
Under Clearing the selection will, I put Keep set values. This will keep the last selection in the view. I then clicked OK.
Now the blue bar will change when you click on the Sub-Category button and will display the percentage in the tooltip.
Comments