Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

thewillemzelluf
New Contributor II

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
MVP
MVP

Re: 0 in calculation

0 or NULL?

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

Re: 0 in calculation

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

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

thewillemzelluf
New Contributor II

Re: 0 in calculation

does rangesum also work with *?

MVP
MVP

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.

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

MVP
MVP

Re: 0 in calculation

thewillemzelluf
New Contributor II

Re: 0 in calculation

thankyou,

my calcuation now is:

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

MVP
MVP

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.

Community Browser