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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
MohTawfik
Resolver I
Resolver I

DAX conditional format is not working with Blank/ No data cells!

I have Matrix visual where I want to write a DAX formula to format cells based on two conditions, their values and status!

 

Expected ValueStatusFormat Background colorRemarks
>0WonGreenWorking fine
>0LostBlackWorking fine
>0In process / Open / StoppedYellowWorking fine
=0 RedWorking fine
Blank / No Data Rednot working

 

MohTawfik_0-1683106138491.png

My problem is blank / no data cells are not formatted correct and doesn't return red color
and this is the formula I used to format!

ColorRule Opp_Background =


Var Opp_status =
SELECTEDVALUE(
    Opportunity[Lifecycle Status (Opportunity)]
)

Var Expected_Value =
sum(
    Opportunity[Expected Value]
)

Var Result_Opp =
SWITCH(
    True(),
    Expected_Value <= 0,
    "Red",
    isblank(Expected_Value),
    "Red",
    Expected_Value > 0 && Opp_status = "Lost" ,
    "Black",
    Expected_Value > 0 && or(Opp_status = "In Process",Opp_status = "Open") ,
    "Yellow",
    Expected_Value > 0 && Opp_status = "Stopped",
    "Yellow",
    "Green"
)

Return

    Result_Opp
  [  isblank(Expected_Value),
    "Red",]
   This part is not working !!!!!
6 REPLIES 6
MohTawfik
Resolver I
Resolver I

@v-jianboli-msft 
Thanks for the reply, but I got exactly the same result, still blank cells are not formated!!

Hi @MohTawfik ,

 

What does your original data look like?

Please check what exactly are these blank values?

Here are some decuments about this, hope they could help you:

How to handle BLANK in DAX measures - SQLBI

Handling BLANK in DAX - SQLBI

 

Best Regards,

Jianbo Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks for your continues support, I came across these two topics but still stuck.

That's a sample file with my data and formula to check

Conditional Format.pbix 

Hi @MohTawfik ,

 

With your PBIX file I found the problem:
The conditional formatting doesn't work because the blank cells you see don't actually exist, they are created by the intersection of rows and columns. Using blank() doesn't work because they are not values in any real sense.


So if you want them to be conditionally formatted the way you want, the easiest way is to change the default color of the cells in Visual to red, and then conditionally format the other values:

vjianbolimsft_0-1683530811803.png

Final output:

vjianbolimsft_1-1683531013286.png

Best Regards,

Jianbo Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks again, I actually did this solution however it's not very practical as I have different levels of heirarcy where I don't want to keep the same format!
it's a bit complex one ! 🥴

v-jianboli-msft
Community Support
Community Support

Hi @MohTawfik ,

 

Please try:

 

SWITCH(
    True(),
    Expected_Value <= 0,
    "Red",
    Expected_Value = BLANK(),
    "Red",
    Expected_Value > 0 && Opp_status = "Lost" ,
    "Black",
    Expected_Value > 0 && or(Opp_status = "In Process",Opp_status = "Open") ,
    "Yellow",
    Expected_Value > 0 && Opp_status = "Stopped",
    "Yellow",
    "Green"
)

Return

    Result_Opp

 

Best Regards,

Jianbo Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.