Forum Discussion

harib's avatar
harib
Icon for Post Patron rankPost Patron
7 years ago
Solved

Conditional background color based on the other column

Hello Friends,

 

Is it possible to create background color for column based on the other column  like below table.

I have a Target and Performance column. Based on the Target ,performance column background should come.

Condition : if Performance > Target Green should come and if Performance < Target Red should come.

 

Target    Performace

75%         30%

85%        90%

65%        70%

 

Thanks in advance

  • So, the easiest way to do this would be to create a measure like:

     

    Indicator = 
    VAR __target = MAX('Table'[Target])
    VAR __performance = MAX('Table'[Performance])
    RETURN
    IF(__performance < __target,"Red","Green")

    Then you can base your conditional formatting off of that measure.

4 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Icon for Community Champion rankCommunity Champion

    So, the easiest way to do this would be to create a measure like:

     

    Indicator = 
    VAR __target = MAX('Table'[Target])
    VAR __performance = MAX('Table'[Performance])
    RETURN
    IF(__performance < __target,"Red","Green")

    Then you can base your conditional formatting off of that measure.

  • Mariusz's avatar
    Mariusz
    Icon for Community Champion rankCommunity Champion

    Hi harib 

     

    Yes, you can do the following.

    Create a measure like below, you can replace my sum aggregation with Measures.

    Conditional Formatting = 
    INT( SUM( YourTable[Performance] ) > SUM( YourTable[Target] ) 

    In table visual, under Filters > Values, right click on the field you want to apply the formatting on and go to Conditional formatting > Background color.

    Nesxt, make sure you set everything as on the screenshot below.

    Let me know if you ned any extra help

    Best Regards,
    Mariusz

    If this post helps, then please consider Accepting it as the solution.

    Please feel free to connect with me.
    Mariusz Repczynski

     

     

     

     

    • harib's avatar
      harib
      Icon for Post Patron rankPost Patron

      Mariusz 

       

      Hi Mariusz,

      Forgot to inform you . Performance is a measure. It's not a column. Output  is not coming

      If both are columns then it's working superb.

       

      Can u please look into that .Thanks in advance

       

      Thanks

      • Mariusz's avatar
        Mariusz
        Icon for Community Champion rankCommunity Champion

        Hi harib 

        Please see the below Measure adjusted for use with Measure, the rest is the same as previous post.

        Conditional Formatting = 
        INT( [Performance]  > [Target] ) 
        Best Regards,
        Mariusz

        If this post helps, then please consider Accepting it as the solution.

        Please feel free to connect with me.
        Mariusz Repczynski