Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
qlikplaut
Partner - Contributor III
Partner - Contributor III

SUM of null in script

Hello everyone,

I have a problem.

I have a field with normal values and null values. When perform a group by in the script with sum(field), the result returns 0 even if the values are null. I even tried placing a 'N' when null, but i get the same result sum(field)=0 for these values. I want the sum of null values to be a null value as well.

Basically I have this:

for values=null or 'N', sum(field)=0

I need this:

for values=null or 'N', sum(field)=Null or 'N' and not 0

Thank you,

Bogdan

1 Solution

Accepted Solutions
hic
Former Employee
Former Employee

Well, Sum(field) is 0 if field is NULL... So QlikView does the right thing.

If your Group By in the script looks like the following:

Load

     Dimension,

     Sum(Number) as NumberSum

     From ... Group By Dimension ;

Then you might get NumberSum=0 for some values of "Dimension". If you want to omit these records, you should simply add a Where clause, e.g.:

Load

     Dimension,

     Sum(Number) as NumberSum

     From ... Where IsNum(Number)

     Group By Dimension ;

HIC

View solution in original post

2 Replies
alexandros17
Partner - Champion III
Partner - Champion III

you cannot unfortunately, because sum gives always 0 even with null values.

hic
Former Employee
Former Employee

Well, Sum(field) is 0 if field is NULL... So QlikView does the right thing.

If your Group By in the script looks like the following:

Load

     Dimension,

     Sum(Number) as NumberSum

     From ... Group By Dimension ;

Then you might get NumberSum=0 for some values of "Dimension". If you want to omit these records, you should simply add a Where clause, e.g.:

Load

     Dimension,

     Sum(Number) as NumberSum

     From ... Where IsNum(Number)

     Group By Dimension ;

HIC