Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Check for nulls vs zero values

In an expression, if you do a sum(X) a 0 value will be returned if data exists and the sum of X = 0 OR no data exists at all.  I'm trying to determine if there is a way to add some logic in my expression so a 0 value will be returned if data exists and the sum of X = 0 and a NULL value will be returned if no data exists at all.  This way I can use the isnull() function to display the zero but not show the null fields.

I hope that makes sense.  Thanks for anything

1 Solution

Accepted Solutions
danielrozental
Master II
Master II

Might be wrong but I don't think you can have sum(of something) return a null value. But you could also do a count so Count(of something) if something is null will get you a 0, if something is zero then you will get 1.

Then you can do something like if(count(something)=0, then do something because its null, sum(something)).

View solution in original post

2 Replies
danielrozental
Master II
Master II

Might be wrong but I don't think you can have sum(of something) return a null value. But you could also do a count so Count(of something) if something is null will get you a 0, if something is zero then you will get 1.

Then you can do something like if(count(something)=0, then do something because its null, sum(something)).

Not applicable
Author

Perfect Daniel thank you, the count() function works great.  You are right the sum() always returns a zero while the count() will return a null!