Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
thewillemzelluf
Creator
Creator

0 in calculation

Hello everyone,

I have a problem with the addition of the purchase. The sum that I use for this is: number * number in package * number of carts + other. However, if one of these is 0 then this calculation is already wrong. Someone any idea how I can solve this within qliksense?

Thanks in advance!

7 Replies
swuehl
MVP
MVP

0 or NULL?

If you are adding parts that could be NULL, try Rangesum()

sunny_talwar

May be use RangeSum() instead of +... something like this

RangeSum(Exp1, Exp2, Exp3, ....)

thewillemzelluf
Creator
Creator
Author

does rangesum also work with *?

swuehl
MVP
MVP

Could you post your complete expression and a sample of the field values?

Consider using something like

Alt(FIELD,0)

to handle NULL for a single field, for example in a product

=Alt(FIELD1,0) * Alt(FIELD2,0)

Always consider using aggregation functions in an expression.

If you are using Sum( as outer Aggregation, you probably can just use

=Sum( FIELD1 * FIELD2)

Rangesum() can be used to handle NULL in an addition

Rangesum(FIELD1, FIELD2)   // FIELD1+FIELD2

Rangesum(FIELD1*FIELD3, FIELD2) // FIELD1*FIELD3+ FIELD2

swuehl
MVP
MVP

thewillemzelluf
Creator
Creator
Author

thankyou,

my calcuation now is:

KOLLI*INHOUD*KALEPRIJS+REST*KALEPRIJS as Totaalprijs,

swuehl
MVP
MVP

And do you need to handle NULL or is there some other issue?

If you one of the fields could be NULL, try

Rangesum(KOLLI*INHOUD*KALEPRIJS, REST*KALEPRIJS) as Totaalprojs,

assuming you want to handle NULL as zero.