So the answer to this is "not easily"!!
Tableau only lets us conditionally format "things" in the calculation canvas, and not the headers. So one way to go about this is to put all the headers into the canvas.
In the attached I've used MIN(number of records) as a dummy axis. I then use the following format to only return a label for the first row
[Name - Category]
IF FIRST()=0 THEN MIN([Category]) END
FIRST() is a Table Calculation which equals zero for the first mark in a partition. So we set this up like this
By un-ticking Name, we are saying create a partition on this. As there is no else part to the statement, all other marks equate to NULL and so don't get drawn. I also used the Gantt mark type (and set it's transparency to zero), as this is the best mark-type for "lining text up")
I then repeated this for each header. I then un-tick "show header" on the real headers.
Once we have this we can colour the text, by adding a colour pill to the "name" axis and changing the text to "match mark colour". As we now have axis we don't get a column label, so I created these on a seperate sheet and put them together in a dashboard.
For the colour I created another version of your calculation, which returned the order 1,2,3...and then used a WINDOW_MIN (another table calc) to find the lowest value for each Name)
So not easy, and not for the faint hearted.
Hope that helps
Colour Header.twbx 36.1 KB
Thank You Simon. You have been really helpful always. That solves it !