Forum Discussion

Keshavpooja's avatar
Keshavpooja
Frequent Visitor
4 years ago

Conditional Formatting based on rules with dynamic conditions from slicer selection

Hi Experts,

 

I have a conditional formatting set in a Matrix based on rules which checks for the values in certain range and display traffic light icons accordingly. The screenshot is atttached below.

 

Now I would need to change this logic of threshold check based on slicer selection. For instance, when the user selects Market=A, the above threshold shown in the image should work i.e. Red Light=0-0.5, Yellow Light=0.5-0.9, Green Light=0.9-1. When the user selects Market=B, the threshold check should be Red=0-0.7, Yellow=0.7-0.8, Green=0.8-1

 

Could you pls guide me with this approach 

 

Mvh,

Kesavan.

5 Replies

  • Keshavpooja where is the logic for each customer that drives the range? Do you have it in a table somewhere?

    • Keshavpooja's avatar
      Keshavpooja
      Frequent Visitor

      Hi,

       

      As shown in the image, the threshold value ranges are directly used in the Rules and not stored anywhere in table. Until now all the Markets have been following the same threshold but now one of the Markets is going to follow a different threshold which i am not sure how to implement.

      • negi007's avatar
        negi007
        Community Champion

        Keshavpooja in this case, i suggest you to create a calc column like below there you can define sepeate condition for market A and Other markets.

         

        So you can code color green with 1 and yellow with 2 and red with 3 like below

         

        Color_coding =
        var _sla_va = 'Table'[SLA Fullment]
        return
        if ('Table'[Market] = "A" ,
        SWITCH(TRUE(),
        _sla_va>=0.9,1,
        _sla_va>=0.5,2,
        _sla_va>=0,3
        ),
        SWITCH(TRUE(),
        _sla_va>=0.8,1,
        _sla_va>=0.7,2,
        _sla_va>=0,3
        )
        )
         
        then in the conditional formatting of your matrix you can put condition like below
         

         

        below is the final output

         

         

        i have attached the pbix file for your reference as well. 

         

         

  • Keshavpooja Although negi007 has provided the solution if tomorrow there is another change, you have to come and update the measure and I always think of the solution from the scalability point of view. Check my video on conditional formatting where you store the data in an external source and any future change can be easily made without making the changes in the model. https://youtu.be/s3riB6EtqkY

     

    Just my 2 cents.

     

     

    Follow us on LinkedIn and  to our YouTube channel

     

    Learn about conditional formatting at Microsoft Reactor

    My latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

     

    Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.