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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
prasadswamy
New Member

I want to color specific cells that is diagonal of a matrix.

prasadswamy_0-1731581431305.png

 

I want to color specific cells that is diagonal of a matrix. As shown in 1st figure but when in a row all values zero the formula does not get apply.
Here is the formula :
conditionalformatting :
if(
   (
column = Q2 && row Q1 ||
column = Q3 && row Q1 ||
column = Q4 && row Q1 ||
column = Q3 && row Q2 ||
column = Q4 && row Q2 ||
column = Q4 && row Q3 
) && [value] = 0,
"#808080","FFFFFF"
)
In figure two when all values in rows are zero it is not getting applied to the row :

prasadswamy_1-1731581569905.png

 





 

3 ACCEPTED SOLUTIONS
MFelix
Super User
Super User

Hi @prasadswamy ,

 

Try the following code:

 

Condittional Format = 
			VAR OverallCalculation = CALCULATE(
					SUM('Table'[Value]),
					REMOVEFILTERS('Table'[Quarter 2])
				)
			RETURN
				SWITCH(
					TRUE(),
					((SELECTEDVALUE('Table'[Quarter 1]) = "Q1" && SELECTEDVALUE('Table'[Quarter 2]) = "Q2") ||
					(SELECTEDVALUE('Table'[Quarter 1]) = "Q1" && SELECTEDVALUE('Table'[Quarter 2]) = "Q3") ||
					(SELECTEDVALUE('Table'[Quarter 1]) = "Q1" && SELECTEDVALUE('Table'[Quarter 2]) = "Q4") ||
					(SELECTEDVALUE('Table'[Quarter 1]) = "Q2" && SELECTEDVALUE('Table'[Quarter 2]) = "Q3") ||
					(SELECTEDVALUE('Table'[Quarter 1]) = "Q2" && SELECTEDVALUE('Table'[Quarter 2]) = "Q4") ||
					(SELECTEDVALUE('Table'[Quarter 1]) = "Q3" && SELECTEDVALUE('Table'[Quarter 2]) = "Q4")) && SUM('Table'[Value]) = 0 && OverallCalculation <> 0, "#808080"
				)

MFelix_0-1731583424903.png

 

MFelix_1-1731583447345.png

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

danextian
Super User
Super User

Hi @prasadswamy 

Why do you need to include zero? If the value is not blank the conditional formatting would be applied as well granting that it met the other conditions.

danextian_0-1731583702424.png

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

Bibiano_Geraldo
Super User
Super User

Hi, @prasadswamy ,
To ensure that the conditional formatting is applied even when all values in a row are zero, you can modify your formula to include a check for rows where all values are zero. Here’s an updated version of your formula:

conditionalformatting = 
IF(
    (
        (column = "Q2" && row = "Q1") ||
        (column = "Q3" && row = "Q1") ||
        (column = "Q4" && row = "Q1") ||
        (column = "Q3" && row = "Q2") ||
        (column = "Q4" && row = "Q2") ||
        (column = "Q4" && row = "Q3")
    ) && [value] = 0,
    "#808080",
    IF(
        SUMX(
            FILTER(
                'Table',
                'Table'[row] = EARLIER('Table'[row])
            ),
            'Table'[value]
        ) = 0,
        "#808080",
        "FFFFFF"
    )
)


This should ensure that the formatting is applied correctly even when all values in a row are zero.

if this help you, please consider to mark as solution and give a Kudo.

 

Thank you

View solution in original post

3 REPLIES 3
Bibiano_Geraldo
Super User
Super User

Hi, @prasadswamy ,
To ensure that the conditional formatting is applied even when all values in a row are zero, you can modify your formula to include a check for rows where all values are zero. Here’s an updated version of your formula:

conditionalformatting = 
IF(
    (
        (column = "Q2" && row = "Q1") ||
        (column = "Q3" && row = "Q1") ||
        (column = "Q4" && row = "Q1") ||
        (column = "Q3" && row = "Q2") ||
        (column = "Q4" && row = "Q2") ||
        (column = "Q4" && row = "Q3")
    ) && [value] = 0,
    "#808080",
    IF(
        SUMX(
            FILTER(
                'Table',
                'Table'[row] = EARLIER('Table'[row])
            ),
            'Table'[value]
        ) = 0,
        "#808080",
        "FFFFFF"
    )
)


This should ensure that the formatting is applied correctly even when all values in a row are zero.

if this help you, please consider to mark as solution and give a Kudo.

 

Thank you

danextian
Super User
Super User

Hi @prasadswamy 

Why do you need to include zero? If the value is not blank the conditional formatting would be applied as well granting that it met the other conditions.

danextian_0-1731583702424.png

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
MFelix
Super User
Super User

Hi @prasadswamy ,

 

Try the following code:

 

Condittional Format = 
			VAR OverallCalculation = CALCULATE(
					SUM('Table'[Value]),
					REMOVEFILTERS('Table'[Quarter 2])
				)
			RETURN
				SWITCH(
					TRUE(),
					((SELECTEDVALUE('Table'[Quarter 1]) = "Q1" && SELECTEDVALUE('Table'[Quarter 2]) = "Q2") ||
					(SELECTEDVALUE('Table'[Quarter 1]) = "Q1" && SELECTEDVALUE('Table'[Quarter 2]) = "Q3") ||
					(SELECTEDVALUE('Table'[Quarter 1]) = "Q1" && SELECTEDVALUE('Table'[Quarter 2]) = "Q4") ||
					(SELECTEDVALUE('Table'[Quarter 1]) = "Q2" && SELECTEDVALUE('Table'[Quarter 2]) = "Q3") ||
					(SELECTEDVALUE('Table'[Quarter 1]) = "Q2" && SELECTEDVALUE('Table'[Quarter 2]) = "Q4") ||
					(SELECTEDVALUE('Table'[Quarter 1]) = "Q3" && SELECTEDVALUE('Table'[Quarter 2]) = "Q4")) && SUM('Table'[Value]) = 0 && OverallCalculation <> 0, "#808080"
				)

MFelix_0-1731583424903.png

 

MFelix_1-1731583447345.png

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors