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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

conditional background color for specific complete columns in the matrix

Hi,

I want the background color for complete 3 columns in my matrix in this way as shown below where my condition would be like- if Table(percentage) = "D(75-90%)" then "yellow" and so on. But I'm not able to do it using conditional formatting. Can someone tell the measure I should use?

mansagar_1-1617979452235.png

When I'm using the measure:

COLOUR =

IF (HASONEFILTER(FinalManipulatedTable[Percentage])
,IF( FIRSTNONBLANK('FinalManipulatedTable'[Percentage] , 0) = "D(75-90%)"
,"yellow"
,IF( FIRSTNONBLANK('FinalManipulatedTable'[Percentage] , 0) = "E(90-100%)"
,"orange"
,IF( FIRSTNONBLANK('FinalManipulatedTable'[Percentage] , 0) = "Z>100"
,"red"
,"white"
)))
,BLANK()
)
Its not including the blank cells in color and showing the below matrix:

mansagar_0-1617979345806.png

Please help!

13 REPLIES 13
Anonymous
Not applicable

@Anonymous 

Emm, or can you share the pbix file after removing or changing sensitive data?

 

Paul Zheng _ Community Support Team

PaulDBrown
Community Champion
Community Champion

@Anonymous 

You can achive this be referencing the column directly in your measure. Here is an example in a matrix with "Channel" from (DIm Channel Table) are the columns and two measures for values (Sum of Sales and target)

result.JPG

 

condit formt.JPG

 

Using this measure as for the conditional formatting:

Column colour = SWITCH(TRUE(),
    MAX('DIM Channel'[Channel]) = "B", "Red",
    MAX('DIM Channel'[Channel]) = "D", "Green")




Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Anonymous
Not applicable

Its giving weird results. Please see:

mansagar_0-1617982134335.png

mansagar_1-1617982188535.png

 

Am I missing something?

@Anonymous 

 

OK, here is way to colour the blanks. First create a new measure to substitute blanks with 0 using a measure along the lines of:

no blanks measure = [your measure] + 0

 

In my example:

 

 

 

Sum of Sales + 0 = [Sum of Sales] + 0

 

 

 

Use this measure in the matrix and the measure for the conditional column. In my example:

 

 

 

Column colour = SWITCH(TRUE(),
    MAX('DIM Channel'[Channel]) = "B", 1,
   MAX('DIM Channel'[Channel]) = "D", 2)

 

 

 

column colour.JPG

 

And you will get this:

result.JPG

If you want to show blanks instead of 0, create a new measure to use for the conditional formatting for the font referecning the original measure (which returns blanks):

 

 

 

0 value condit column = 
SWITCH(TRUE(),
    AND(ISBLANK([Sum of Sales]), MAX('DIM Channel'[Channel]) = "B"), 1,
    AND(ISBLANK([Sum of Sales]), MAX('DIM Channel'[Channel]) = "D"), 2,
     ISBLANK([Sum of Sales]), 3)

 

 

 

Now use this measure in the conditional formatting for the font:

font.JPG

 

font condit.JPG

 

 

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Anonymous
Not applicable

I don't know why but any measure is not replacing blanks with anything, even if I add 0. Thanks for the solutions though. 

@Anonymous 

 

Can you show the DAX for the original measure and the + 0 measure and the result in the visual?





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Anonymous
Not applicable

Originally I'm not using any measure. I'm just using count of a column in values as you can see in the below image. So I am not able to create this measure you talked about:

no blanks measure = [your measure] + 0

mansagar_2-1617989234686.png

 

 

 

@Anonymous 

Use a measure instead.

Count Tasks = COUNT(table[Task]) 

and take it from there





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Anonymous
Not applicable

No change in the result even after I add 0 to measure. Its not replacing the blank cells.

 

mansagar_0-1617992202995.png

 

amitchandak
Super User
Super User

@Anonymous , you need check blank for the measure too

,IF( FIRSTNONBLANK('FinalManipulatedTable'[Percentage] , 0) = "D(75-90%)"  && (isblank([Mesure]) || not(isblank([measure]))) ,"yellow"

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Did not work. Still showing the same result. Is there any other way?

Anonymous
Not applicable

Hi,

 

But I don't have any measure to put in (isblank([Measure]) since i'm using a column name of the table 'FinalManipulatedTable'[Percentage] to create this measure 'colour'.

@Anonymous , use min('FinalManipulatedTable'[Percentage]) in place of that and check.

 

What measure is displayed/used  in values of a matrix, use that

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.