Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
1 year ago
Solved

Conditional Formatting for Column Color based on different KPIs

I try to conditional format different sets of data simultaneously through a bar chart that navigates through different KPIs through a slicer, I want the column to be colored green if the value is greater than or equal to the target value for example, I have listed the conditions below:

  • MC Eff: green if greater than or equal target , red otherwise
  • Weigher Eff: green if greater than or equal target , red otherwise
  • GGA: green if less than or equal target , red otherwise
  • Film Waste: green if less than or equal target , red otherwise
  • R&M and Operating Supplies: No formatting ( stay default orange color)

I have tried making a nested IF function and placed into a measure and then corresponding the output of the measure to the conditional formatting in the visual formatting as attached in the pics below but there's some kind of conflict that occurs that makes all the colors interfere with each other. The code i used is also pasted below:

 

 

 

Spoiler
Color Change MC Eff. = IF('MC Efficiency (%)'[MC Efficiency (%)]>'MC Efficiency (%)'[MC Efficiency T],"green",IF('Weigher Efficiency (%)'[Weigher Efficiency (%)]>'Weigher Efficiency (%)'[Weigher Efficiency T],"green",IF('GGA (gm)'[GGA (gm)]<'GGA (gm)'[GGA T],"green",IF('Film Waste (%)'[Film Waste (%)]<'Film Waste (%)'[Film Waste T],"green",IF(OR('Operating Supplies'[Operating Supplies Measure],'R&M'[R&M]),"orange","red")))))

 

I also tried to modify the code to this but also no use:

 
Spoiler
Color Change MC Eff. = IF(
    SELECTEDVALUE('KPI'[KPI]) = "MC Efficiency (%)" &&
     'MC Efficiency (%)'[MC Efficiency (%)]>='MC Efficiency (%)'[MC Efficiency T],"green",
     IF(SELECTEDVALUE('KPI'[KPI]) = "Weigher Efficiency (%)" &&
     'Weigher Efficiency (%)'[Weigher Efficiency (%)]>='Weigher Efficiency (%)'[Weigher Efficiency T],"green",IF(SELECTEDVALUE('KPI'[KPI])="GGA" &&
     'GGA (gm)'[GGA (gm)]<='GGA (gm)'[GGA T] ,"green",
     IF( SELECTEDVALUE('KPI'[KPI]) = "Film Waste (%)" &&
     'Film Waste (%)'[Film Waste (%)] <= 'Film Waste (%)'[Film Waste T], "green",
     IF(OR(SELECTEDVALUE('KPI'[KPI]) ="R&M", SELECTEDVALUE('KPI'[KPI])="Operating Supplies"),"orange","red")
     ))))
 
Please advise on how I can resolve this problem
 
  • Hi Anonymous 

     

    I've written this so you can make them all seperate tests if you want to using the individual switches.

     

    Color Change MC Eff. =
    VAR currMeasure =
        SELECTEDVALUE ( 'KPI'[KPI] )
    RETURN
        SWITCH (
            currMeasure,
            "MC Efficiency (%)", SWITCH ( TRUE (), [MC Efficiency (%)] > [MC Efficiency T], "Green" ,"Red"),
            "Weigher Efficiency (%)", SWITCH ( TRUE (), [Weigher Efficiency (%)] > [Weigher Efficiency T], "Green","Red" ),
            "GGA", SWITCH ( TRUE (), [GGA (gm)] < [GGA T], "Green","Red" ),
            "Film Waste (%)", SWITCH ( TRUE (), [Film Waste (%)] < 'Film Waste (%)'[Film Waste T], "Green","Red" ),
            "R&M", "orange",
            "Operating Supplies", "orange",
            "Red" --If anything else
        )

6 Replies

  • Hi Anonymous 

     

    I've written this so you can make them all seperate tests if you want to using the individual switches.

     

    Color Change MC Eff. =
    VAR currMeasure =
        SELECTEDVALUE ( 'KPI'[KPI] )
    RETURN
        SWITCH (
            currMeasure,
            "MC Efficiency (%)", SWITCH ( TRUE (), [MC Efficiency (%)] > [MC Efficiency T], "Green" ,"Red"),
            "Weigher Efficiency (%)", SWITCH ( TRUE (), [Weigher Efficiency (%)] > [Weigher Efficiency T], "Green","Red" ),
            "GGA", SWITCH ( TRUE (), [GGA (gm)] < [GGA T], "Green","Red" ),
            "Film Waste (%)", SWITCH ( TRUE (), [Film Waste (%)] < 'Film Waste (%)'[Film Waste T], "Green","Red" ),
            "R&M", "orange",
            "Operating Supplies", "orange",
            "Red" --If anything else
        )

    • SamWiseOwl's avatar
      SamWiseOwl
      Icon for Super User rankSuper User

      Hi Anonymous 

      The GGM needs to be GGM (gm) to match what it is in the slicer:

       

      • Anonymous's avatar
        Anonymous
        Not applicable

        that's great!! but still the greater than or equal has problems
        it should be colored green as the target is 99.5% as well

         

  • Anonymous's avatar
    Anonymous
    Not applicable

    SamWiseOwl It turned out to be rounding figures as u mentioned, thanks a lot for the support