Do you enjoy working with Tableau? Are you looking for an additional challenge? Workout Wednesday might be what you need. WorkoutWednesday a set of weekly challenges from Andy Kriebel and Emma Whyte (for 2017) and Rody Zakovich and Luke Stanke. (For 2018) designed to test your knowledge of Tableau and help you improvise your development skills. The idea is to replicate the challenge that they pose as closely as possible. When you think you have it, leave a comment with a link to your visualization and post a pic on Twitter for others to enjoy.
2017 WorkoutWednesday Challenge: Link
This week Andy is back with a challenge and it’s very straightforward. You need to create two quarters starting with the month selected and show months for everything else.
- Sub-Categories are sorted in Descending order by Total Sales in the Year
- Each Month will Highlight the MIN Sales in Red, Max Sales in Blue.
- Pay attention to formatting and how the Table adjusts in size according to how many Sub-Categories are being shown
- Allow users to Filter by Year and/or Category
As per the instruction, you can use your own Superstore Data or you can use the dataset available at Data.World
First, create an account on Data.World and copy the tableau link by clicking on the Download icon as per the below image.
The moment you click on “Tableau Icon”, a new Popup will open which contains a connector URL.
Copy the highlighted URL and open the web Connector API.
Paste the Copied URL and Press Enter. Now your Tableau is connected to the given dataset.
Drag Month (Order Date) on the column shelf, Sub- Category on the Row Shelf and Zn(Sum(sales)). As per the requirement, we need to sort our Sub-Categories in Descending order by Total Sales.
Now next step is to highlight the MIN Sales in Red, Max Sales in Blue for each column. I tried a couple of ways before opting the actual Solution. Some of them are mentioned below which may not be useful for the particular condition but these are helpful when we are dealing with Grand Total columns. You can try by taking the sample data and applying the below logic.
Approach 1: last () = first ()
Add the above-calculated field on the color shelf and compute using specified dimensions which are available on the view.
Approach 2: MIN (DATEPART (‘month’, [Order Date])) ==Max(DATEPART(‘month’, [Order Date]))
Approach 3: Size () = 1
Drag the above-calculated field on the color shelf. Make sure your calculated field computes using “Table Down”
For highlighting the Cells, I am using the Gnatt bar as my marks and adding a constant integer Avg (1) on Size shelf.
I was happy with the end result but I wanted to challenge myself. I thought of adding a different color on Grand Total which should highlight the min and max of Grand Total Column.
So I created 3 different calculated field
1. One that highlights the Min value in the entire table
2.One that highlights the Max value in the entire table
3.One that highlights the Max and Min value in the Grand Total Column.
Now we have everything in place, just add all the calculated field in one calculation by using the OR Condition and put it into Colour shelf along with other two calculated fields.
Now as per the requirement, it should allow users to filter by year and /or category.
Note: Here, we are using the Fixed LOD in our calculated fields which usually executes before the Dimension filter. So to avoid this, we will convert the Dimension/ categorical filter into the context Filter. As we know that, Context filter as being an independent filter. They are used when we don’t want all the values to come up in the filters rather we want only the relevant values to come up.