cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
savvari Frequent Visitor
Frequent Visitor

calculated column doesn't show blanks

I have a column in the dataset (Query), which has 3 values: 1, 0 and null.

When creating visualizations, I figured I need a different representation of that column. So, I created a Calculated Column:

 

CalcCol = IF(Col1 = 1, "Yes", IF( Col1 = 0, "No", Blank()))

 

But I see only Yes, No values in the new calculated column. I don't see Blanks at all. I think they are combined with No.

 

However, if I crate a Custom column in Edit Queries window to achieve the same, I get all three values.

 

I want to understand why this is the case and would really like to have the calculated column work the desired way, instead of having to create Custom column in edit queries (where it means refreshing the entire dataset and is clumsy given I have lot of huge queries).

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Re: calculated column doesn't show blanks

@savvari

This is the intended behaviour. Where boolean logic is involved, blanks are considered as having a numeric value of zero and boolean value of FALSE. What you are essentially saying here is, IF Col 1 = Zero or FALSE, then "No". A boolean comparison of a blank cell to the value of zero ( i.e. IF FALSE = FALSE) equates to TRUE and NOT FALSE, and hence the result. Therefore, one way is to not only compare the values, but also the datatype.

 

 

CalcCol =
IF (
    Table1[Col1] = 1,
    "Yes",
    IF ( ISNUMBER ( Table1[Col1] ) && Table1[Col1] = 0, "No", BLANK () )
)

 

2 REPLIES 2

Re: calculated column doesn't show blanks

@savvari

This is the intended behaviour. Where boolean logic is involved, blanks are considered as having a numeric value of zero and boolean value of FALSE. What you are essentially saying here is, IF Col 1 = Zero or FALSE, then "No". A boolean comparison of a blank cell to the value of zero ( i.e. IF FALSE = FALSE) equates to TRUE and NOT FALSE, and hence the result. Therefore, one way is to not only compare the values, but also the datatype.

 

 

CalcCol =
IF (
    Table1[Col1] = 1,
    "Yes",
    IF ( ISNUMBER ( Table1[Col1] ) && Table1[Col1] = 0, "No", BLANK () )
)

 

Highlighted
savvari Frequent Visitor
Frequent Visitor

Re: calculated column doesn't show blanks

Thanks @nikhilmekala

 

It makes sense. But it's confusing and the expectation is not clear because it behaves differently in Edit Queries window.

 

In the Edit Queries window, I used "Column from Example" option for Adding a column. Had Yes for 1, No for 0 and left nulls as is. That have me three values in the new column. Isn't it the same thing as Boolean logic? I also used Conditional Columns with Rules for 1 and 0. Even in that case, I got Nulls.

 

I'm perplexed as to the difference in behavior between the two cases: Edit Queries window vs Report. 

Helpful resources

Announcements
Community Highlights

Community Highlights

Find out what's new in the Power BI Community!

Summit North America

Power Platform Summit North America

Register by September 5 to save $200

Virtual Launch Event

Microsoft Business Applications Virtual Launch Event

Watch the event on demand for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

MBAS Gallery

Watch Sessions On Demand!

Continue your learning in our online communities.

Users Online
Currently online: 380 members 4,469 guests
Please welcome our newest community members: