7 Replies Latest reply: Jun 26, 2018 8:22 AM by Stefan Wühl

# 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?

• ###### Re: 0 in calculation

0 or NULL?

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

• ###### Re: 0 in calculation

does rangesum also work with *?

• ###### Re: 0 in calculation

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.

Use Aggregation Functions!

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

• ###### Re: 0 in calculation

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

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

• ###### Re: 0 in calculation

thankyou,

my calcuation now is:

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

• ###### Re: 0 in calculation

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.