Forum Discussion

PThompson1888's avatar
PThompson1888
Regular Visitor
4 years ago
Solved

Conditional Formatting - Multiple Criteria

Hi All,

 

I am currently trying to implement some conditional formatting based on 3 criteria and would really appreciate some help if possible.

 

The 3x columns I have:

- Product Profit ($)

- Parts Profit ($)

- Margin (%)

 

I am trying to complete some colour coding based on the combinations of criteria below
- IF Product Profit ($) = (>0) AND Parts Profit ($) = (>0) AND Margin (%) = (>0) - should be coloured green.
- IF Product Profit ($) = (<0) AND Parts Profit ($) = (>0) AND Margin (%) = (>0) - should be coloured yellow.
- IF Product Profit ($) = (<0) AND Parts Profit ($) = (<0) AND Margin (%) = (<0) - should be coloured red.

Would really appreciate some help or guidance on this!

  • Hi PThompson1888 

    Try this measure

    measure = 
        var _a= min('Table'[Product Profit])
        var _b= min('Table'[Parts Profit])
        var _c= min('Table'[Margin])
    return 
        SWITCH(TRUE(),
        _a>0 && _b>0 && _c>0,"Green",
        _a<0 && _b>0 && _c>0,"Yellow",
        _a<0 && _b<0 && _c<0,"Red")

    Best Regards,

    Community Support Team _Tang

    If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

5 Replies

  • PThompson1888 , Not able to get the logic. But this logic if you can create a measure, then you can use that in conditional formatting using field value option

     

    example

     

    Switch( True() ,
    [Percent] =1 , "Green"
    [percent] <.75 , "red",
    [percent] <.99 , "Yellow"
    )

     

    How to do conditional formatting by measure and apply it on pie?: https://youtu.be/RqBb5eBf_I4

    • PThompson1888's avatar
      PThompson1888
      Regular Visitor

      Hi amitchandak - I have tried to make my logic more clear by updating my initial post. The criteria I would have are 'AND' rather than having the suggestion above which would only take into account one column in my data (margin percent). 

      Does the updated post clarify a little on what I am trying to do?

  • v-xiaotang's avatar
    v-xiaotang
    Community Support

    Hi PThompson1888 

    Try this measure

    measure = 
        var _a= min('Table'[Product Profit])
        var _b= min('Table'[Parts Profit])
        var _c= min('Table'[Margin])
    return 
        SWITCH(TRUE(),
        _a>0 && _b>0 && _c>0,"Green",
        _a<0 && _b>0 && _c>0,"Yellow",
        _a<0 && _b<0 && _c<0,"Red")

    Best Regards,

    Community Support Team _Tang

    If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

    • sizi's avatar
      sizi
      Helper II

      Hello all,

       

      I have a similar requirement wherein I need to define user's occupancy in a month based on number of projects assigned during the time period.  Ex: For January month if a user has 6 projects planned between Jan 5-Jan 25, 1st project is falling between Jan 5th-Jan10th, 2nd & 3rd project between Jan 10-Jan15th and Last 3 project between Jan 16th-Jan 25th, then for the 1st condition, the timeline should be relatively free colored green, for 2nd condition, it should be medium as there's 2 projects and colored yellow and for the last 3 project it should be high colored red and all this needs to defined based on demands and start and end date of task.

      Basically If one task then free = green, 2 task then medium =yellow and if user has 3 task and more than highly busy = red based on dates overlap. I need this to be visualised.

       

      Below is the sample data. 

       

      Task NumberUsersStart DateComplete Date
      101John1/1/20245/1/2024
      102John6/1/202411/1/2024
      103John6/1/202411/1/2024
      104John6/1/202411/1/2024
      105John12/1/202417/1/2024
      106John12/1/202417/1/2024
      107John18/1/2202423/1/2024
      108John18/1/2202423/1/2024
      109John18/1/2202423/1/2024
      110John18/1/2202423/1/2024
      111John18/1/2202423/1/2024
      112John18/1/2202423/1/2024
      113Bethany1/1/20244/1/2024
      114Bethany1/1/20244/1/2024
      115Bethany5/1/20246/1/2024
      116Bethany6/1/202411/1/2024
      117Bethany6/1/202411/1/2024
      118Bethany18/1/2202423/1/2024
      119Bethany18/1/2202423/1/2024
      120Bethany18/1/2202423/1/2024
      121Bethany24/1/202430/1/2024
      122Bethany24/1/202430/1/2024
      123Bethany24/1/202430/1/2024
      124Bethany24/1/202430/1/2024

       If user a has task >=1 at a time then it shall show green,

      If user has task = 2 at a time then it shall show yellow.

      And if user has task > 2 at a time then red. All this shall be based on RG start & RG completion date. 

      If there are 5 user, each user shall have a bar showing his occupancy in either green, yellow or red based based on dates.

      KIndly help. Thanks in advance.