cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
gabriela Regular Visitor
Regular Visitor

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

Accepted Solutions
Super User
Super User

Re: DAX treats 0 as BLANK: how to prevent it?

Hi @gabriela

 

USe this instead

 

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

View solution in original post

3 REPLIES 3
Super User
Super User

Re: DAX treats 0 as BLANK: how to prevent it?

Hi @gabriela

 

USe this instead

 

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

View solution in original post

gabriela Regular Visitor
Regular Visitor

Re: DAX treats 0 as BLANK: how to prevent it?

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 

Super User
Super User

Re: DAX treats 0 as BLANK: how to prevent it?

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)

 

 

 

 

Helpful resources

Announcements
Can You Solve These Challenge

Challenge: Can You Solve These?

Find out how to participate in the first Power BI 'Can You Solve These?' challenge.

Community News & Announcements

Community News & Announcements

Get your latest community news and announcements.

Virtual Launch Event

Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

Community Kudopalooza

Win Power BI Swag with Community Kudopalooza!

Each week, complete activities and be qualified in the drawing for cool Power BI Swag.

Users Online
Currently online: 46 members 1,080 guests
Please welcome our newest community members: