Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
kapildua16
Helper I
Helper I

Conditional Formatting Dax

Hi @Everyone 
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

2 ACCEPTED SOLUTIONS
Akash_Varuna
Super User
Super User

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.

View solution in original post

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

View solution in original post

6 REPLIES 6
v-dineshya
Community Support
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

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

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

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

Akash_Varuna
Super User
Super User

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.
MattiaFratello
Super User
Super User

Hi @kapildua16

 

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

MattiaFratello_0-1741080843161.png

 

MattiaFratello_1-1741081033600.png



MattiaFratello_2-1741081042832.png


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

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.