2 Replies Latest reply on May 9, 2018 10:43 PM by Zubair S

    Conditional Coloring for a Single Dimension Column

    Zubair S

      Hello Everyone,


      I am working on a Tableau Worksheet. I need to color the entities of a specific dimension column, based on a condition related to the marks field.


      My worksheet looks similar to the screenshot below:


      I need to change the font colors of the fields under the "Name" Column, based on the "status(es)" related to that particular Name field.

      If you see the image above, I have the "Status" field in the marks column. So the fields under "Name" column should be of the same color as of the lowest color of the statuses column.


      The hierarchy of status colors is as follows:





      So Red being the lowest color, if any of the statuses related to a particular "Name" field is red, then the font color of that name field should be red.

      Else it should look for the color yellow and if no yellow, then it should look for the color green. Hence depending on the lowest color of the statuses related to a particular Name field, the font color of that Name field should change as well.


      I have included the tableau workbook within this post. I would appreciate any kind of assistance regarding my query.


      Thanks and regards,


        • 1. Re: Conditional Coloring for a Single Dimension Column
          Simon Runc

          hi Zubair,


          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

          • 2. Re: Conditional Coloring for a Single Dimension Column
            Zubair S

            Thank You Simon. You have been really helpful always. That solves it !