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
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
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.