How to compare Year over Year values in Tableau

The challenge that started it all

The Alpha #WOW challenge

Remember your roots

I’m on a mission to complete and record or livestream all solutions to every #WOW challenge since 2017. And it all starts right here with this challenge. This is the challenge that started it all in 2017. Andy, off the heals of the first year of #MakeoverMonday, kicked off his next weekly challenge project, #WorkoutWednesday. 

So here we go with Challenge no. 1. You can watch the solution below. I’ve collected my calculated fields below the video player. 

Enjoy!

The calculations

The first thing we need is to calculate the day of year and thankfully, Tableau provides as DATEPART operator

//Day of Year
DATEPART('dayofyear',[Order Date])

We also need to take of our parameter control value and format it to the calculate at the right value

//Target_ref
[Target]/100
Next we need to calculate the % of Total Sales
//% of Total Sales  
RUNNING_SUM(COUNTD([Order ID]))/TOTAL(COUNTD([Order ID]))
Now let’s calculate the first date at or above the target 
//First % above ref line
if 
    window_min(if [% of Total Orders]>=[Target_ref] then [% of Total Orders] END) = if [% of Total Orders]>=[Target_ref] then [% of Total Orders] END
then
    if [% of Total Orders]>=[Target_ref] then [% of Total Orders] END
END
Lastly we need a calculation to highlight our max year
//Line Color
YEAR([Order Date])={max(YEAR([Order Date]))}

GO FORTH AND VIZ!

Check out the interactive visualization below

Skip to content