cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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

Accepted Solutions
Highlighted
Super User III
Super User III

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 )
Try my new Power BI game Cross the River

View solution in original post

3 REPLIES 3
Highlighted
Super User III
Super User III

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 )
Try my new Power BI game Cross the River

View solution in original post

Highlighted
Helper I
Helper I

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 

Highlighted
Super User III
Super User III

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)

 

 

 

 

Try my new Power BI game Cross the River

Helpful resources

Announcements
Meet the 2020 Season 2 Power BI Super Users!

Meet the 2020 Season 2 Power BI Super Users!

Find out who's part of the program this season, and welcome the new Super Users.

August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

July 2020 Community Highlights

July 2020 Community Highlights

Learn about the exciting things that happened in July.

Featured Data Story of The Month

Featured Data Story of The Month

All Data Stories Gallery contributions are reviewed for each month. We select a contribution and feature the community member the following month.

Power BI Dev Camp - Developing with .NET Core

Power BI Dev Camp - Developing with .NET Core

Learn how to develop custom web applications for Power BI using .NET Core 3.1 and .NET 5.

Top Solution Authors
Top Kudoed Authors