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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
gabriela
Helper I
Helper I

DAX treats 0 as BLANK: how to prevent it?

Hello,

 

I have a data with many missing values for variable X and I'd like to do a simple transformation of this variable such as adding 3 to all values. 

 

I tried the formula below:

 

X_new = if('Data'[X]  = BLANK (); BLANK(); 'Data)'[X] + 3)

 

And it works almost perfectly (returns BLANK for those rows which have missing value) but the problem is that now also the rows with value = 0 are treated as BLANK. So, in the end, I have more missing values for variable X_new than for original variable X.

 

I'd appreciate suggestion how to deal with this problem.

 

Gabriela

1 ACCEPTED SOLUTION
Zubair_Muhammad
Community Champion
Community Champion

Hi @gabriela

 

USe this instead

 

X_New =
IF ( NOT ( ISBLANK ( Data[X] ) ), Data[X] + 3 )

Regards
Zubair

Please try my custom visuals

View solution in original post

3 REPLIES 3
Zubair_Muhammad
Community Champion
Community Champion

Hi @gabriela

 

USe this instead

 

X_New =
IF ( NOT ( ISBLANK ( Data[X] ) ), Data[X] + 3 )

Regards
Zubair

Please try my custom visuals

Thank you @Zubair_Muhammad for such a quick reply. It worked perfectly!

 

The follow-up question: do you know why 0 were treated as missing values (BLANK) with my formula? I'm trying to understand the syntax of DAX. 

 

Thanks,

Gabriela 

Hi @gabriela

 

The problem comes from the "=" OPERATOR

 

In DAX terms

BLANK() = 0 = true

but

ISBLANK(0)= FALSE

 

So formulas below give different results

=if('Data'[X]  = BLANK (), BLANK(), 'Data'[X] + 3)

=if(ISBLANK('Data'[X]) , BLANK(), 'Data'[X] + 3)

 

 

 

 


Regards
Zubair

Please try my custom visuals

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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