Forum Discussion

kapildua16's avatar
kapildua16
Helper I
1 year ago
Solved

Conditional Formatting Dax

Hi Anonymous 
I need some help in defining logic for confitional formatting for matrix visual
I have below data

Row LabelsSundayMondayTuesdayWednesdayThursdayFridaySaturday
7 AM18201716114611
8 AM27453227229429
9 AM57909432156216639
10 AM63131137133852525052
11 AM471205468208612734
12 PM2989635110039334
1 PM3071514269410020
2 PM238752626368037
3 PM255948444868227
4 PM2955593633810426
5 PM245851393217236
6 PM394242432877733
7 PM313129211844225
8 PM243023181954729
9 PM393929191994837
10 PM412820171826442
11 PM29232010976433

I need to apply conditional formatting on each cell of matrix
I want to divide the values of matrix in 5 differnet percentage group which is

0-20%

21 to 40%

41 to 60%

61 to 80%

81 to 100%

 

and apply a differnet background color for each ranges.
based on the dataset, the 20 percentile is 27, 40 percentile is 37.4, 60 percentile is 52, 80 percentile is 95.2 and 100 percentile is 8525
so value less than 27 should be in different color and so on

  • Hi kapildua16 Another way is through a measure you could also try if you want 

    1. Create a DAX Measure: Define a measure that assigns a numeric category (1–5) based on the value in the matrix.

      PercentileCategory = 
      VAR CurrentValue = SELECTEDVALUE(MatrixTable[Value]) -- Replace with your column name
      RETURN 
          SWITCH(
              TRUE(),
              CurrentValue < 27, 1,        -- 0-20%
              CurrentValue <= 37.4, 2,    -- 21-40%
              CurrentValue <= 52, 3,      -- 41-60%
              CurrentValue <= 95.2, 4,    -- 61-80%
              TRUE(), 5                   -- 81-100%
          )
    2. Apply Conditional Formatting:

      • Go to your matrix visual, select the field you want to format, and navigate to Conditional Formatting > Background Color.
      • Choose Format by: Field Value.
      • Select the PercentileCategory measure.
      • Assign colors to categories:
        • Category 1 (0–20%): Light color.
        • Category 2 (21–40%): Slightly darker shade.
        • Category 3 (41–60%): Medium color.
        • Category 4 (61–80%): Darker color.
        • Category 5 (81–100%): Bright or bold color.
  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi, kapildua16 

    I wish you all the best. Previously MattiaFratello and Akash_Varuna have provided a solution to help you solve the problem. Since we haven't heard back from you yet, I'd like to confirm if you've successfully resolved this issue or if you need further help?
    If yes, you are welcome to share your workaround and mark it as a solution so that other users can benefit as well. If you find a reply particularly helpful to you, you can also mark it as a solution.
    If you still have any questions or need more support, please feel free to let us know. We are more than happy to continue to help you.
    Thank you for your patience and look forward to hearing from you.

     

     

    Best Regards

    Jianpeng Li

6 Replies

  • Hi kapildua16

     

    Please right-click on the column you used in Values (in your matrix) -> Conditional Formatting -> Background Color

     




    If I answered your question please feel free to mark it as an answer!

  • Hi kapildua16 Another way is through a measure you could also try if you want 

    1. Create a DAX Measure: Define a measure that assigns a numeric category (1–5) based on the value in the matrix.

      PercentileCategory = 
      VAR CurrentValue = SELECTEDVALUE(MatrixTable[Value]) -- Replace with your column name
      RETURN 
          SWITCH(
              TRUE(),
              CurrentValue < 27, 1,        -- 0-20%
              CurrentValue <= 37.4, 2,    -- 21-40%
              CurrentValue <= 52, 3,      -- 41-60%
              CurrentValue <= 95.2, 4,    -- 61-80%
              TRUE(), 5                   -- 81-100%
          )
    2. Apply Conditional Formatting:

      • Go to your matrix visual, select the field you want to format, and navigate to Conditional Formatting > Background Color.
      • Choose Format by: Field Value.
      • Select the PercentileCategory measure.
      • Assign colors to categories:
        • Category 1 (0–20%): Light color.
        • Category 2 (21–40%): Slightly darker shade.
        • Category 3 (41–60%): Medium color.
        • Category 4 (61–80%): Darker color.
        • Category 5 (81–100%): Bright or bold color.
  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi, kapildua16 

    I wish you all the best. Previously MattiaFratello and Akash_Varuna have provided a solution to help you solve the problem. Since we haven't heard back from you yet, I'd like to confirm if you've successfully resolved this issue or if you need further help?
    If yes, you are welcome to share your workaround and mark it as a solution so that other users can benefit as well. If you find a reply particularly helpful to you, you can also mark it as a solution.
    If you still have any questions or need more support, please feel free to let us know. We are more than happy to continue to help you.
    Thank you for your patience and look forward to hearing from you.

     

     

    Best Regards

    Jianpeng Li

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

    Hi kapildua16 ,

    Thank you for reaching out to the Microsoft Community Forum.

     

    Step-by-step DAX Measure for Conditional Formatting:

    1.DAX measure that categorizes the values into those 5 percentile buckets:

    Cell Color Group =
    VAR CellValue = SELECTEDVALUE('YourTable'[Value])
    RETURN
    SWITCH(
    TRUE(),
    CellValue < 27, "#d73027", -- 0-20%
    CellValue < 37.4, "#fc8d59", -- 21-40%
    CellValue < 52, "#fee08b", -- 41-60%
    CellValue < 95.2, "#d9ef8b", -- 61-80%
    CellValue <= 8525, "#91cf60", -- 81-100%
    "#FFFFFF"
    )

    Applying the Conditional Formatting: Select your Matrix visual.

    Click on the values dropdown in the Visualizations pane. Choose Conditional Formatting > Background color. Select Field value. Pick the Cell Color Group measure from the dropdown.

    2.Show Percentile Group: If you want to show which group each value falls into as a label:

    Percentile Group Label =
    VAR CellValue = SELECTEDVALUE('YourTable'[Value])
    RETURN
    SWITCH(
    TRUE(),
    CellValue < 27, "0-20%",
    CellValue < 37.4, "21-40%",
    CellValue < 52, "41-60%",
    CellValue < 95.2, "61-80%",
    CellValue <= 8525, "81-100%",
    "N/A"
    )

     

    If my response has resolved your query, please mark it as the Accepted Solution to assist others. Additionally, a 'Kudos' would be appreciated if you found my response helpful.

    Thank you

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

      Hi kapildua16 ,

      As we haven’t heard back from you, we wanted to kindly follow up to check if the solution provided for the issue worked? or Let us know if you need any further assistance?
      If our response addressed, please mark it as Accept as solution and consider giving a KUDOS. Feel free to reach out if you need further assistance.

       

      Regards,

      Dinesh

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

        Hi kapildua16 ,

        As we haven’t heard back from you, we wanted to kindly follow up to check if the solution provided for the issue worked? or Let us know if you need any further assistance?
        If our response addressed, please mark it as Accept as solution and consider giving a KUDOS. Feel free to reach out if you need further assistance.

         

        Regards,

        Dinesh