A bar chart where only the latest year is highlighted

Tableau Design – Dynamic Year over Year Colours

Learn how to use MAX and WINDOW_MAX functions in Tableau to dynamically apply colours to year-over-year data comparisons.

One of the (many) limitations Tableau has when it comes to applying colours to a chart is that the colour is applied to the data as a static colour. This doesn’t work well when you want to compare year over year data. Sure, you can apply a colour data that exists in 2023, but what happens when the calendar turns to to the next calendar year? There’s no data to apply a colour to.

This is where MAX and WINDOW_MAX comes in.

design.MaxYear

  • Create Calculated Field
  • Name the new calculated field (I like to use design.MaxYear since it allows me to quickly filter any new calculations that’s specific to design)
  • Copy and paste the following code – updating [Order Date] to match your Date metric
IF max(year([Order Date]))=window_max(max(year([Order Date]))) THEN 1
ELSE 0
END
  • Convert your calculation from a Continuous to Discrete
  • Drag and drop the calculation to the Colour tab
  • Apply the colours you want to the latest Year and the remaining years

The finished result: latest year highlighted, previous years muted

You can watch the video here

Video walkthrough of the design.MaxYear calculation

Comments

Need help with your analytics setup?

We configure GA4, build dashboards, and fix attribution for B2B companies.

Let's Talk