Forum Discussion

Marico's avatar
Marico
Icon for Helper IV rankHelper IV
4 years ago
Solved

Conditionally formatting % values in a table based on slicer selection

I have a requirement where the background color of the numbers needs to be changed based on the slicer selection. The sales column is of the "Percentage" data type.

 

- If the Region is selected as East, the sales is less than 50% then "RED" else "GREEN"

- If the Region is selected as West, the sales are less than 60% then "RED" else "GREEN"

 

CountryPopulationSales
Sweden          119,99750%
Germany            16,77770%
USA            10,00030%
India            34,07840%
Netherlands            46,76790%
Japan            78,99965%

 

Slicer values:

Region:

- East

- West

4 Replies

  • Marico , a Color measure

     

    Switch( true() ,

    selectedvalue(Table[Region]) = "East" && [Sales] <.5, "Red" ,

    selectedvalue(Table[Region]) = "East" && [Sales] >=.5, "Green" ,

    selectedvalue(Table[Region]) = "West" && [Sales] <.6, "Red" ,

    selectedvalue(Table[Region]) = "West" && [Sales] >=.6, "Green" )

     

     

    Use this measure in conditional formatting using field value option

     

    How to do conditional formatting by measure and apply it on pie?
    https://www.youtube.com/watch?v=RqBb5eBf_I4&list=PLPaNVDMhUXGYo50Ajmr4SgSV9HIQLxc8L
    https://community.powerbi.com/t5/Community-Blog/Power-BI-Conditional-formatting-the-Pie-Visual/ba-p/1682539

  • amitchandak Kudos! This works well. 

    However, I have 5 such fields like Sales where the above type of conditional formatting needs to be applied in the table.

     

    1. Would I need to create 5 different measures for each field like the one above?

    2. Will combining in the single measure and using it in conditional formatting (field value) would also work?

    3. What will happen when user selects "Select All" option instead of either "East" or "West"?

     

    Appreciate your support!

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

      Marico , Assume another measure is margin and you want to color margin based on margin %, then I would advise creating a new measure.

       

      if every thing is based on sales , then just use switch , if etc and create one measure

       

      • Marico's avatar
        Marico
        Icon for Helper IV rankHelper IV

        amitchandak Sure, thanks

         

        What will happen when user selects "Select All" option instead of either "East" or "West" - Will it show the values based on threshold of East or West in that case?

         

        Client has a requirement wherein they want to have the "Select All" option enabled in the slicer along with "East" and "West".