This week’s #WOW2025 challenge was a guest post by Kieran Adair and had two parts to it; one to show Sales and Profit Ratio for 2024 only on the same chart, and the other to show comparisons to 2023 data on the same chart.
I built the first one way, and had to make changes in order to build the second. I could have chosen to rebuild the first chart using the fields I ended up creating for the second, but I chose not to, so this will ultimately be 2 blogs in one, as for each chart I needed different fields.
Restricting the data
We only need data for 2023 and 2024 for this challenge, so apply a data source filter (right click data source > Add data source filter) and restrict to Years 2023 and 2024 only.
Building the 2024 chart
We will be plotting Profit Ratio so need to create
Profit Ratio
SUM([Profit])/SUM([Sales])
format this to % with 0 dp.
Add Sub-Category to Rows and Profit Ratio to Columns. Add Order Date to Filter and restrict to the Year 2024 only. Sort the bars descending |(just click the icon on the toolbar)
Change the Mark type to circle and set the colour to black. Widen the rows a little.
Add Sales to Columns. Change the mark type of the sales marks card to bar. Set the colour to white and add a black border.
Adjust the Tooltip on the All marks card and verify both measures are displayed whether hovering over a circle or a bar.
Edit the Sales axis and set to custom to ensure it is fixed to start at 0 and end ‘automatic’. Adjust the axis title to include the text [Bars◻].
Make the chart dual axis BUT DO NOT synchronise axis. Remove Measure Names from the Colour shelf of the All marks card. Right click on the Sales axis at the to and Move marks to back.
Edit the title of the Profit Ratio axis so that it includes the text [Circles ●]. Remove all gridlines and zero lines and hide the Sub-Category row heading (right click the text and hide field labels for rows). Update the title and name the sheet RAVE 2024 or similar.
Building the YoY chart
For this version, we need to create some additional calculated fields
Sales – 2024
IF YEAR([Order Date]) = 2024 THEN [Sales] END
Sales 2023
IF YEAR([Order Date]) = 2023 THEN [Sales] END
Profit – 2024
IF YEAR([Order Date]) = 2024 THEN [Profit] END
Profit 2023
IF YEAR([Order Date]) = 2023 THEN [Profit] END
PR – 2024
SUM([Profit – 2024])/SUM([Sales – 2024])
format to % with 0dp
PR – 2023
SUM([Profit – 2023])/SUM([Sales – 2023])
format to % with 0dp
On a new sheet, add Sub-Category to Rows and PR – 2024 to Columns. Sort descending. Change the mark type to circle.
Drag PR – 2023 onto the PR -2024 axis and release the mouse when the 2 green column symbol appears.
This will automatically update the viz to include Measure Names and Measure Values. Adjust the Colour legend so PR 2024 is black and PR 2023 is grey, and PR 2024 is listed first (so black circles are on top when the marks overlap)
Add Sales 2024 to Columns. Change the mark type of the Sales 2024 marks card to bar. Remove Measure Names from the Colour shelf of the Sales 2024 marks card. Set the colour to white and add a black border.
Add Sales – 2023 to the Detail shelf of the Sales 2024 marks card. Right click on the Sales 2024 axis and Add Reference Line per cell referencing the Sales 2023 value as below.
Update the title of the Sales – 2024 axis to Sales [Bars◻] and set the axis to be fixed from 0 to automatic. Update the title of the other axis (Value) to Profit Ratio [Circles ●].
On the All marks card add PR 2023, PR 2024, Sales – 2023 and Sales -2024 to the Tooltip shelf and update to suit.
Make the chart Dual Axis but once again DO NOT synchronise the axis. As before move the marks (bars) of the Sales axis to the back, and remove the Sub-Category label. Remove all gridlines and zero lines and update the title.
And that’s it. I added both my sheets to dashboards, juts to improve the presentation slightly. My published viz is here.
This week, Kyle set the challenge of recreating area charts combined with a tile map / small multiple. He’d been inspired by a viz he uses at work, which he then realised had actually been inspired by a previous #WorkoutWednesday challenge from 2020 which I actually blogged about here.
So some of the steps for this solution guide, I’ll lift from my existing blog :-), but there are no table calcs in this instance.
Building the basic tile map
As per Kyle’s instructions, I started by building a new field that I could then format to millions
Pop
[Population (Population)] * 1000
I formatted this to be a custom number with 2 dp and displayed with Millions unit.
Put this into a table where State and Date on Rows and Pop on Text, just so we can validate what we’re up to…
We need to standardise/normalise the display, so the population for each State is ranging from 0 to 1. For this we need to determine
Min Pop Per State
{FIXED [State]:MIN([Pop])}
Max Pop Per State
{FIXED [State]:MAX([Pop])}
and we can then work out
Standardised Pop
(SUM([Pop]) – SUM([Min Pop per State]))/(SUM([Max Pop per State]) – SUM([Min Pop per State]))
Format this to display as a number with 2 dp. Add all 3 fields to the table. For each state the Standardised Pop should have a year when then value is 0 (equivalent to when the population is lowest for the state) and a year when the value is 1 (equivalent to when the population is highest for the state).
For the tile map, we also need fields Rows and Cols which are calculations that map each State to a number (and can be copied straight from the challenge sheet).
On a new sheet, add Rows to Rows (as a discrete dimension) and Cols to Columns (also as a discrete dimension). Add State to Detail. Your initial ‘map’ layout should start to take shape.
Add Date to Columns and set to be a the continuous Year level (green pill) and add Standardised Pop to Rows. Set the display to Entire View, so all the tiles are visible.
Change mark type to Area and add Pop to the Tooltip. Update the Tooltip as required.
Adding the State label and max value
For this we’re going to plot a single point that will be at the centre of the Date axis and slightly higher than 1. For this we need
This looks a bit complex, so I’ll break it down. What we’re doing is finding the number of years between the minimum year in the whole data set (1900) and the maximum year in the data set (2023). This is
We’re then halving this value ( /2) and rounding it down to the nearest whole number (FLOOR).
We then add this number of years to the minimum date in the data set (DATEADD), to get our central year – 1961.
Now we need a point where we can plot a mark against that date. It needs to be above the maximum value in the area chart (which is 1). Based on what I did before, I decided 1.75 worked
Plot State Label
IF YEAR([Date]) = YEAR([Centre Date]) THEN 1.75 END
Add Plot State Label to Rows between Rows and Standardised Pop. Change the mark type of this axis to shape and use a transparent shape (see here for info). Note you can use a circle and reduce size to smallest and opacity to 0% if you wish. However, this will show a small dot when hovering, which you don’t get with a transparent shape.
Add Max Pop per State to Label and change State from Detail to Label. Adjust the Label accordingly
Remove all text from the Tooltip dialog of the Plot State Label marks card, and hide the Nulls indicator label. Make the chart dual axis and synchronise the axis. Remove Measure Names from the All marks card.
Then remove all gridlines, zero lines, axis lines and row/column dividers. Hide all the axis and the Cols and Rows pills (uncheck show header).
Building the bar chart
Create a new field
Latest Pop per State
IF [Date] = {FIXED [State]:MAX([Date])} THEN [Pop] END
If the date is the maximum date for the state, then get the population. Format this to be 2dp in Millions.
Add State to Rows and Latest Pop for State to Columns and sort descending. Adjust the colour to suit. Show mark labels, and remove all gridlines etc and row/column dividers and hide the axis. Adjust the Tooltip.
Creating the highlight action
Add the two sheets to a dashboard. Add a dashboard highlight action
Highlight State
On hover of the bar chart, target the map, via the State field only.
In the final week of ‘alternative charts month’, Luke set this challenge as different way of presenting data that you might typically see in a side-by-side bar chart.
Luke had indicated on the #WOW splash screen, that this challenge was ‘easy’, but that’s always dependent on your level of Tableau. He also added a note in the requirements that if you wanted to be ‘advanced’ to solve it with Table Calcs only.
I figured I’d just start and see what I ended up with (sometimes, my natural brain thinking takes me down a table calc route..)
In a change to my usual starting point, I started trying to remember what I needed to do to get the comet… I felt pretty sure that path would be involved somewhere.
So, I added Order Date to the Filter shelf and filtered to years 2021 and 2022 only.
Then I added Sub-Category to Rows, Sales to Columns and Order Date (which defaulted to YEAR(Order Date)) to Detail. I changed the mark type to circle initially.
Ok – I had what I was expecting – 2 circles per row, one for each year.
So then I change the mark type to line and moved YEAR([Order Date]) from Detail to Path. This meant my lines were joined.
I then added Order Date to Size, and reset Order Date to be at the YEAR level. Hey presto! My comet shapes appeared.
I now wanted to show a white circle mark just for the 2022 sales, so I created
Max Year Sales LOD
{FIXED [Sub-Category]:SUM(IF YEAR([Order Date]) = {FIXED:MAX(YEAR([Order Date]))} THEN [Sales] END)}
this looks a bit long-winded ( I do usually break this up)… so let’s review what’s going on…
{FIXED:MAX(YEAR([Order Date]))} returns the latest year in the data set (ie 2022) and spreads that across every row of data. So the formula is comparing each row, and if the Order Date year matches 2022, the value of the Sales is returned. This is then all aggregated and totalled for each Sub-Category.
Add this field to Columns, make dual axis and synchronise axis.
Remove Measure Names from the All marks card and change the mark type of the Max Years Sales LOD card to circle. Colour white.
Remove the YEAR([Order Date]) pill from the Size shelf of the Max Years Sales LOD card, so the size of the comet (the Sales card) and the circle can be adjusted independently. Adjust the sizes enough so the comet is visible around the circle.
Sort the Sub-Category field by Max Year Sales LOD descending
Next we need to colour the comets based on whether Sales increased or decreased.
Prev Year Sales LOD
{FIXED [Sub-Category]: SUM( IF YEAR([Order Date]) = {FIXED:MAX(YEAR([Order Date]))} -1 THEN [Sales] END)}
is doing similar to the above calculation, but {FIXED:MAX(YEAR([Order Date]))} -1 returns 2021 instead.
and with this we can created
Sales Increased? LOD
[Max Year Sales LOD] > [Prev Year Sales LOD]
Add this to the Colour shelf of the Sales marks card, and adjust accordingly.
To label the comets, check the show mark labels checkbox on the Label shelf dialog, and set to line ends and label end of line. You may need to check the allow labels to overlap option too if you’re not seeing all the labels.
The dashboard shows a circular size legend which is related to the circle mark, so I created
Order Date (Years)
YEAR([Order Date])
and added this to the Size shelf of the Max Year Sales LOD marks card.
Add Sales to the Tooltip shelf of the Max Year Sales LOD marks card too and adjust the tooltips.
Add row dividers, and remove all column dividers, gridlines and axis. Adjust the formatting of the Sub-Category row labels and hide the column title. Set the background of the worksheet to a grey colour.
And so that ended up being the LOD version of the chart, which is accessible from here.
But I had time, so I figured I’d see if I could crack the Table calcs version…
Building the Table Calculation Solution
This starts by repeating the intial steps above to get a basic single axis comet chart for Sales, split by Year.
We now need to get the sales for 2022 only. For starters, let’s identify the latest year
Latest Year
WINDOW_MAX(MAX(YEAR([Order Date])))
and let’s build up a table, so we can start to sense check what’s going on, as table calcs can be pesky!
Our Latest Year table calc is returning 2022 for every row in our table. To get the sales just for 2022
Window Max Year Sales
WINDOW_MAX(IF MIN(YEAR([Order Date]))=[Latest Year] THEN SUM([Sales]) END)
if the order date year is 2022, then return Sales (otherwise null) and spread the maximum value across the rows. When we add this into the table, we need to set the table calculation to compute using Year or Order Date, so that it is calculating the WINDOW_MAX for each Sub-Category
Add this field to Columns on the comet chart, and adjust the table calculation so Window Max Year Sales is computing by Year of Order Date only, and Latest Year by both fields (see the Nested Calculations dropdown)
Make the chart dual axis, and synchronise the axis. Make the adjustments to the mark types and sizes as described above.
We can’t sort the Sub-Category field in the way we did above, as table calculation fields aren’t accessible in the sort dialog. Instead add Window Max Year Sales to Rows and change it to be discrete (blue pill) and move it to be in front of Sub_Category. Adjust the table calc settings to match that described above. This should make the chart sort ascending.
To reverse, double click into the blue Window Max Year Sales pill on Rows and add * -1 to the end
Annoyingly this will revert it back to a measure, so reapply the steps above, and you should end up with a correctly sorted display. Hide the Window Max Year Sales blue pill.
Now to colour the comet.
Back to the tabular view. Add a Difference quick table calculation to the Sales pill and edit the table calculation to compute using Year(Order Date) only.
Drag the Sales pill with the difference table calc from the Measure Values section and drop into the left hand data pane. This will create a dedicated instance of the calculation. Rename it to
Sales Diff – TC
ZN(SUM([Sales])) – LOOKUP(ZN(SUM([Sales])), -1)
If you examine it, it should contain the above calculation.
With this we can then work out if sales have increased or not
Adding this into the table, and setting the nested table calcs to both compute by Year Order Date, you can see that the values for each Sub-Category are either 1 or 0.
Add this to the Colour shelf of the Sales marks card. Make sure the field is discrete and the table calcs are set to compute by Year Order Date. Adjust the colours.
Finally make adjustments for the tooltip and adjust the formatting to clean up the chart. My table calc version of the viz is here.
It was time for Lorna to add her iteration to the dashboard challenge that’s been set over the last few weeks. The challenge this week was to incorporate a measure swap control which allows the user to select which measures they want to compare.
Lorna gave the option to build out either your own or an already published solution, or to build a simpler brand new viz that just demonstrates the technique.
By incorporating this measure swap control into an existing solution, existing calculated fields and other objects will need to be adjusted/renamed. I started to build against my own solution, but that already had multiple instances of calculated fields where I’d chosen to change from a table calculation version in week 5 to an LoD based solution in week 6. I decided instead to use Kyle’s solution from week 7, which is published here.
However, for the purposes of this blog, I will build out the simple solution, so the focus is on what you need to do to build the control.
Building the Measure Selector
So to start, I simply copied the text for the secondary data source off the challenge page
I then opened Tableau Desktop, connected to the Orders sheet of the relevant Superstore Sales excel spreadsheet, then on the Data menu, selected Paste, which added a ‘clipboard’ data source and presented the data on a sheet.
To start with I chose to Alias the Number field (right click > Aliases) to map the numbers in the data source to the names of the measures we want, as below
The values selected are going to be captured within a parameter, so I then set these up
pMeasureX
Integer parameter defaulted to 1 (ie Sales)
I created a similar pMeasureY too, this one defaulted to 3 (ie Profit Margin).
For the selector control, we need to indicate which measure has been selected, so we need
X Selected?
[pMeasureX]=[Number]
and
Y Selected?
[pMeasureY]=[Number]
I then added Number to Rows and created 3 MIN(1) fields on the Columns shelf
On the first MIN(1) marks card, I changed the mark type to Shape, then added X Selected? to the Shape shelf. I adjusted the shape using options from the Ratings shape palette, and adjusted the size to suit.
On the 2nd MIN(1) marks card, I changed the mark type to Circle, reduced the size to as small as possible, and changed the colour to be completely transparent (Opacity = 0%). I then added Number to the Label shelf, changed the alignment to be Middle Centre, and adjusted the height of the rows, so all the text labels are visible.
On the 3rd MIN(1) marks card, I repeated the steps taken for the 1st marks card, but added Y Selected? to the Shape shelf instead.
I then hid the axes and the Number pill (uncheck Show Header), and removed all row/column borders and gridlines/zero lines.
When this sheet is added to the dashboard, we’re going to need to add parameter actions to pass information from this sheet into the pMeasureX and pMeasureY parameters. For this I found I needed to create copies of the Number field, as using the same field to control both selectors caused me some issues. So I created
Number (X)
[Number]
and added this to the Detail shelf of the 1st MIN(1) marks card.
And then
Number (Y)
[Number]
which was added to the Detail shelf of the 3rd MIN(1) marks card.
Another feature of this sheet when added to the dashboard, is we don’t want the circle selected to be highlighted/remain selected, so we’ll use a filter action to solve that. But again we need some additional fields on the sheet to help us with that. Create calculated fields
True
TRUE
False
FALSE
And add both of these to the Detail shelf of the All Marks card.
Finally adjust the title of the sheet to contain the text ‘X Select a Measure Y’. You’ll need to play around with the number of spaces to use. It’s best to wait until the sheet is on the dashboard to get it right.
Building the Scatter Plot
On a new sheet, the first thing needed for this challenge is to create
Profit Ratio
SUM([Profit])/SUM([Sales])
Now we need to define fields that will determine what measure to display based on the value stored in the relevant parameter
X Measure
CASE [pMeasureX] WHEN 1 THEN SUM([Sales]) WHEN 2 THEN SUM([Profit]) WHEN 3 THEN [Profit Ratio] WHEN 4 THEN SUM([Quantity]) END
Y Measure
CASE [pMeasureY] WHEN 1 THEN SUM([Sales]) WHEN 2 THEN SUM([Profit]) WHEN 3 THEN [Profit Ratio] WHEN 4 THEN SUM([Quantity]) END
Add X Measure to Columns and Y Measure to Rows, and add State to Detail.
We need to label the X & Y axis based on the name of the selected measure, so we need
X Dimension
CASE [pMeasureX] WHEN 1 THEN ‘Sales’ WHEN 2 THEN ‘Profit’ WHEN 3 THEN ‘Profit Ratio’ WHEN 4 THEN ‘Quantity’ END
Add this to the Columns shelf
Y Dimension
CASE [pMeasureY] WHEN 1 THEN ‘Sales’ WHEN 2 THEN ‘Profit’ WHEN 3 THEN ‘Profit Ratio’ WHEN 4 THEN ‘Quantity’ END
Add this to the Rows shelf
Edit both axes and remove the title from both. Right click on the word ‘Profit Ratio’ and Rotate Label. Right click on ‘X Dimension’ at the top and select hide field labels for columns. Right click on ‘Y Dimension’ on the left and select hide field labels for rows. Format to remove the row and column gridlines.
The State a user clicks on/selects needs to be captured within a parameter
pSelectedState
String parameter defaulted to New Jersey
We then need to determine if the State matches that selected
Is Selected State?
[State]= [pSelectedState]
Change the mark type to Circle, then add Is Selected State? to the Colour shelf and adjust to suit. Add a border to the mark too. Drag the ‘True’ value on the colour legend so its listed above ‘False’.
Add Is Selected State? to the Size shelf too, and adjust so the sizes are reversed, and alter the range.
Use the slider on the Size shelf too to make all the circles smaller too if need be.
Adjust the Tooltip so the text will be dynamic based on the measure selections too.
Then, modify the title of the sheet, so it too is dynamic.
Finally, this sheet too also needs to ensure the State circle clicked on doesn’t remain ‘selected’ so as above, create a True = TRUE and a False = FALSE calculated fields, and add these to the Detail shelf.
Adding the interactivity
Add both the sheets to a dashboard.
Create the following dashboard actions:
Set X Measure
A parameter action, that runs on Select of the Measure Selector sheet and passes Number (X) into the pMeasureX parameter.
Create a similar parameter action called Set Y Measure that passes Number (Y) into the pMeasureY parameter.
Create a dashboard filter action Selector Sheet – Unhighlight which on select of the Measure Selector sheet on the dashboard, targets the Measure Selector sheet directly, passing True = False into the filter. All values should show when the selection is cleared.
With these 3 actions, you should be able to test what happens when you click the different combinations.
Now we need 2 further dashboard actions
Set Selected State
A parameter action that on select of the Scatterplot passes the State field into the pSelectedState parameter.
Add finally, add another dashboard filter action, Scatter – Unhighlight that on select of the Scatter sheet on the dashboard, targets the scatter sheet directly, passing the fields True = False as the filter.
Hiding the Measure Selector
On the dashboard, select the Measure Selector sheet and select the Add Show/Hide Button from the context menu.
This will create a X button that can then be moved and positioned where required.
On the context menu of the X button, select Hide and the measure selector sheet will disappear, and the X will be replaced by a different image
Select Show from the context menu of this button, and the sheet will reappear. Test the functionality in presentation mode where simply clicking the button will invoke the show/hide behaviour.
And this should be the core functionality to demonstrate this measure swapping feature. My published viz based on this more basic solution is here.
If you’re aiming to build on the viz you’ve built over the last 3 weeks, then you need to replace any references you had to SUM([Sales]) and [Profit Ratio] in the various calculations with the X Measure and Y Measure fields accordingly. You’ll also need to adjust tooltips and titles of the various sheets using the X Dimension and Y Dimension fields as appropriate. My adapted solution built on from Kyle’s week 7 solution is here.
For this week’s challenge, Sean Miller decided to continue with the theme of dashboard extensions, introducing the brush filter extension. The whole of the top section is the extension, so there’s actually only a single chart that needs to be built for this challenge. The main areas of focus for this blog are
The basic chart
Colouring the chart
Identifying the date range
Adding the extension
The basic chart
The chart needs to plot the number of rat sightings vs the Created Date by Borough. The number of sightings is based on the automatically generated field that is related to the name of your data source. To simplify, I created a new field based on this:
# of Sightings
COUNT([2021_02_24_WW08_Rat_Sightings.csv])
and then created the chart as follows
Borough on Columns
Month(Created Date) on Columns as green continuous date pill, formatted to mmm yy
# of Sightings on Rows
Borough on Filter, excluding the value Unspecified
The Boroughs were then manually sorted into the required order.
Colouring the chart
Each Borough needs to be coloured based on the difference between the start & end points. So we need to identify what these are for each Borough. I used table calculations for this
StartCount
WINDOW_MAX(IF FIRST()=0 THEN [# of Sightings] END)
If we’re at the first point in the partition, then record the number of sightings. All the other values in that partition will be NULL. The WINDOW_MAXstatement then takes that value and ‘spreads’ it across all the data points/rows in that partition, as shown below. In this instance the partition is the Borough.
When Start Count is added to the view, the table calculation is set to compute by the Created Date.
We create a similar field for the end point, this time using the LAST() table calculation
End Count
WINDOW_MAX(IF LAST()=0 THEN [# of Sightings] END)
With these two calculated fields, we can now create
Change
IF [End Count]-[Start Count]>0 THEN ‘INCREASE’ ELSEIF [End Count]-[Start Count]< 0 THEN ‘DECREASE’ ELSE ‘NO CHANGE’ END
To be honest, I outputted the words, as I thought I’d be using these in a legend somewhere, but I didn’t. Outputting as values 1, 0 , -1 or similar will have been more efficient.
This field can now be added to the Colour shelf with the table calculation setting applied to compute by Created Date
Identifying the Date Range
As part of the chart title, we need to identify the date range, ie the earliest month and the latest month within the whole window (whole chart). Again we can use table calculations for this
Start Month
WINDOW_MAX(IF FIRST()=0 THEN MIN([Created Date]) END)
If we’re at the first point in the partition (this time the partition is the whole table), then get the Created Date (this is wrapped within a MIN, as the field needs to be an aggregate; using MAX would have worked just as well). The WINDOW_MAX statement once again ‘spreads’ this value across all the rows. This field is formatted to mmmm yyyy
Similarly we have
End Month
WINDOW_MAX(IF LAST()=0 THEN MIN([Created Date]) END)
also formatted to mmmm yyyy.
Both these fields can then be added to the Detail shelf, but this time the table calculation is set as table across. Once on the Detail shelf, the fields can be referenced in the chart title.
Adding the Brush Filter Extension
This challenge makes use of the Brush Filter extension, which you need to download from this link and save the .trex file somewhere appropriate on your machine.
Create a dashboard and add the chart you’ve already built, then add the Extension object to the dashboard. When prompted select My Extensions and browse to the Brush Filter .trex file you’ve saved.
You’ll then be prompted to configure the extension as below, selecting the name of the sheet containing your chart, the Created Date field that will be filtered, and the relevant measure to display. You can then adjust the colours of the ‘filter’ control, and scroll down to save.
As well as a new sightings by month profile chart being displayed, this will have the effect of adding the Created Date to the Filter shelf on your worksheet. The ‘grey’ box over the chart, can then be adjusted by dragging in the ends, or moving the whole box, to apply the required filter.
And apart from formatting adjustments to the chart, that’s all there is to it for today. My published viz is here.