Skip to main content

Hello Tableau Community

 

I am attempting to conditionally color only the sub-totals row of a table using the following calculated field:

 

IF MIN([Category]) != MAX([Category]) THEN

    IF (SUM([% Sales])) < 0.45 THEN 'Total UTIL <45%'

    ELSEIF (SUM([% Sales])) <0.75 THEN 'Total UTIL <75%'

    ELSE 'Total UTIL >75%' END

ELSE '' END

 

. This works perfectly unless there is only one row being used to create the sub-total, causing the IF state to default to the last choice. I understand why it doesnt work but have been unable to find a solution.

 

 

Please assist!!!

 

Packaged workbook attached with Superstore data example.

 

Any assistance is greatly appreciated!

4 answers
  1. Apr 30, 2019, 9:32 AM

    Hi Christopher,

     

    Find my approach as reference below based on an union stored in attached workbook version 10.5 located in the original thread

     

    Hi Christopher, Find my approach as reference below based on an union stored in attached workbook version 10.5 located in the original thread 1. Define a Union 2.

     

    1. Define a Union

    pastedImage_1.png

     

    2. Sub Total & Category: if [Table Name]='Orders' then 'Sub Total' else [Category] end

     

    3. Total Colours: IF (SUM([% Sales])) < 0.45 THEN 'Total UTIL <45%'

        ELSEIF (SUM([% Sales])) <0.75 THEN 'Total UTIL <75%'

        ELSE 'Total UTIL >75%' END

     

    4. if attr([Table Name])='Orders' then [Total Colours] END

     

    Hope it is helpful

     

    Thanks

    Norbert

0/9000