cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
DouweMeer
Post Prodigy
Post Prodigy

Why is my boolean not working?

I just don't get it. It is boolean like :

 

and  () , || and () , || and () , || and () 

 

...and it keep telling me the answer is false. But in red I marked where it should be a True value. As the rest is OR, it should give me True, thus the number 1. I don't get it why it won't give me 1. Anyone?

 

Boolean not working.png

5 REPLIES 5
Anonymous
Not applicable

Hard to exactly tell in that screenshot, any chance you can upload some sample data?

Just found out what is happening. When the field is set as a number and the value for the field is a 0, than the boolean expression will state that the field with the value of 0 is both blank() as it is 0. 

 

You can recreate it by 'enter data', get Column1 on value 0. Then go to the table and enter the if statement:

if ( [column1] = blank() , 1 , 0 ). It will return the value 1. Now change the blank() in the if statement to a 0, and once again, it will return 1. 

 

I don't find the logical. Is this a bug? 

Nope. What I can do, the [Psoft invoice1] has the expression : 

 

Psoft Invoice1 =
VAR a1 = [Invoice 1]
VAR a2 = SELECTCOLUMNS( filter ( 'Psoft' , CONTAINSSTRING( a1 , 'Psoft'[Invoice] )) , "Trans" , 'Psoft'[Transactional amount] )
RETURN
if ( a1 = BLANK() , BLANK() , if ( countx ( a2 , [Trans] ) > 0 , sumx ( a2 , [Trans] ) , 0 ) )
 
And the full expression of the print screen is : 
 
Psoft Value2 =
VAR a1 = [Equation1]
VAR a2 = [Equation2]
VAR a3 = [Equation3]
VAR e4 = if ( [Equation1] = BLANK() && [Equation2] = BLANK() && [Equation3] = BLANK() , [Psoft Invoice1] , 4 )
VAR e3 = if ( and ( ( [Equation1] = 1 || [Equation1] = 3 || [Equation1] = 4 ) , ( [Equation2] = BLANK() && [Equation3] = BLANK() ) ) , [Psoft Invoice1] + [Psoft Invoice2] , e4 )
VAR e2 = if ( a2 = 5 || a2 = 6 , [Psoft Invoice3] , e3 )
VAR e1 = if ( a3 = 5 || a3 = 6 , [Psoft Invoice4] , e2 )
RETURN
if (
and ( [Psoft Invoice1] = 0 , [Psoft Invoice1] <> BLANK() )
|| and ( [Psoft Invoice2] = 0 , [Psoft Invoice2] <> BLANK() )
|| and ( [Psoft Invoice3] = 0 , [Psoft Invoice3] <> BLANK() )
|| and ( [Psoft Invoice4] = 0 , [Psoft Invoice4] <> BLANK() )
, 1
, e1 )
 
 
Anonymous
Not applicable

It probably has to do with the variables. Variables are calculated where you define them, not when you use them. Try without using variables. Also, might want to use SWITCH instead, generally easier to use. 

Myea, have to start using Switch. Regarding the 0, I received the following message from a moderator. 

 

The same issue has been reported before internally: CRI 88868161. 

 

"In DAX, the comparison operator = performs equivalence comparison. Since 0 and BLANK are equivalent values, operator = returns true when comparing 0 to BLANK. Users can use DAX function IsBlank to detect BLANK values."

Helpful resources

Announcements
PBI Sept Update Carousel

Power BI September 2023 Update

Take a look at the September 2023 Power BI update to learn more.

Learn Live

Learn Live: Event Series

Join Microsoft Reactor and learn from developers.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

MPPC 2023 PBI Carousel

Power Platform Conference-Power BI and Fabric Sessions

Join us Oct 1 - 6 in Las Vegas for the Microsoft Power Platform Conference.

Top Solution Authors