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: 
sculptorlv
Creator III
Creator III

SUM values + no value

Hello!

I have the following data:

Name  X1          X2

John    3               1

Alex     2               2

Sara     -               5

I need to make another LOAD in order to get new table with SUM, so the result table should be:

Name  X1          X2          SUM

John    3               1          4

Alex     2               2          4

Sara     -               5          5

I try the code like this:

LOAD

     Name,

     X1,

     X2,

     X1 + X2 AS SUM

RESIDENT Table 1;

As the result, for Sara I got SUM result equel to -.

How can I modify the code in order to make summation correctly?

P.S.: I have about 10 arguments to be summed

Thank you in advance!

1 Solution

Accepted Solutions
marcus_sommer

Just use:

rangesum(X1, X2) AS SUM

- Marcus

View solution in original post

6 Replies
marcus_sommer

Just use:

rangesum(X1, X2) AS SUM

- Marcus

tomasz_tru
Specialist
Specialist

NULL plus any value equals NULL. Use IF and ISNULL function.

sculptorlv
Creator III
Creator III
Author

I did it before, but know I have about 10 arguments ... to complex with IF using in script

rangesum works perfect.

sculptorlv
Creator III
Creator III
Author

Thank you!

tomasz_tru
Specialist
Specialist

Another simple solution:

Alt(X1,0) + X2 AS SUM

sculptorlv
Creator III
Creator III
Author

Didn't know. Thank you, this one is even better!