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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

DAX IF statement insert NULL value

I need to build a calculated column (numeric data type) using IF statement and I need to insert "null" value if condition is met. How to do it in DAX please?

If I use: Score = if('Key Measures'[Score A]=0;"null";'Key Measures'[Score A])  or Score = if('Key Measures'[Score A]=0;"";'Key Measures'[Score A]) 

I get error: Expressions that yield variant data-type cannot be used to define calculated columns.

Which is obvious because I mix numeric and text data types.

 

But how can I insert null/blank value to the cell using DAX? Insert 0 is not solution for me in this case 😞

1 ACCEPTED SOLUTION
andris_
Resolver I
Resolver I

Hey,

 

I'm not sure what the result is that you'd like to get, but with the following formula, you can get blank values :
Score A = if('Key Measures'[Score A]=0;BLANK();'Key Measures'[Score A]) 

 

 

Regards,

Andris

View solution in original post

4 REPLIES 4
andris_
Resolver I
Resolver I

Hey,

 

I'm not sure what the result is that you'd like to get, but with the following formula, you can get blank values :
Score A = if('Key Measures'[Score A]=0;BLANK();'Key Measures'[Score A]) 

 

 

Regards,

Andris

Anonymous
Not applicable

OK, I knew that it was going to be simple, but so simple...

Thank you very much, Andris.

miltenburger
Helper V
Helper V

Hi @Anonymous

 

See this post before, same thing. Should work in your scenario

https://community.powerbi.com/t5/Desktop/How-to-define-the-value-of-a-cell-to-NULL-in-a-quot-IF-quot/m-p/25086

 

Anonymous
Not applicable

Yes, I checked that post already, but that is not my case. That guy needs to count something.

But I need just to insert null (I need empty cell).

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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