THE SQL Server Blog Spot on the Web

Welcome to SQLblog.com - The SQL Server blog spot on the web Sign in | |
in Search

SQLBI - Marco Russo

SQLBI is a blog dedicated to building Business Intelligence solutions with SQL Server.
You can follow me on Twitter: @marcorus

BLANK and Boolean functions like IF in #dax

A recent change in the DAX language transformed the behavior of IF statement, so that it should not return BLANK but only TRUE/FALSE if the results should be logical expressions. In that case, the BLANK is transformed in a FALSE condition.

For example, consider that the result of the following expression is FALSE and not BLANK:

IF ( 1 = 1, BLANK(), TRUE )

I wrote a longer explanation of that, thanks to Jeffrey Wang who provided the details of the implementation. Also a big thanks to Darren Gosbell, who raised the initial question.

Published Wednesday, September 14, 2016 1:04 PM by Marco Russo (SQLBI)
Filed under: , , ,

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

 

Jes Hansen said:

I would love to read the explanation, do you have a link to the explanation?

September 14, 2016 10:13 AM
 

Simon Nuss said:

To clarify: it should not return BLANK but only TRUE/FALSE if *one* of the results should be a logical expression?

I assume this is to ensure that TRUE/FALSE columns can contain only a true() or false(), and never a blank()?

September 14, 2016 12:00 PM
 

Marco Russo (SQLBI) said:

Jes: there was a missing link, now I fixed it - thanks!

Simon: yes, this is the idea, or at least it is close to. Please note that if you have a boolean and an integer, the result of IF is a variant, and it cannot be assigned to a calculated column (for example), unless you write an explicit cast. The case described is just for Boolean + BLANK in an IF.

September 14, 2016 12:43 PM

Leave a Comment

(required) 
(required) 
Submit

About Marco Russo (SQLBI)

Marco Russo is a consultant, writer and trainer specialized in Business Intelligence with Microsoft technologies. He runs the SQLBI.COM website, which is dedicated to distribute resources useful for BI developers, like Integration Services components, Analysis Services models, tools, technical information and so on. Marco is certified as MCT, MCDBA, MCSD.NET, MCSA, MCSE+I.

This Blog

Syndication

Archives

Privacy Statement