Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

PROBLEM - Math Adding On Script Brings Wrong Result

My script has this syntax:

CALCULATED_LINE_COSTS:

  load  [ID],

   COST_GAS,  COST_DEPR,  COST_MAIN,  COST_HWY,  COST_ADMIN, COST_SALARY,

  (COST_GAS + COST_DEPR + COST_MAIN + COST_HWY + COST_ADMIN + COST_SALARY) As  [TOTAL_COST]

  resident  table_10_3;

 

===========================

In qlikview pivot chart, i have an expression- SUM(TOTAL_COST)

The result of it is wrong!

If I create expression summing all costs like this- SUM(COST_GAS) + SUM(COST_DEPR) + ..... and so on.

The result is correct.

Why is the script adding won't work.

Help!!

1 Solution

Accepted Solutions
Not applicable
Author

Hi,

Your fields may contain null values.

Try using Alt(COST_GAS, 0) + Alt(COST_DEPR, 0) + etc... as TOTAL_COST.

View solution in original post

3 Replies
Not applicable
Author

Hi,

Your fields may contain null values.

Try using Alt(COST_GAS, 0) + Alt(COST_DEPR, 0) + etc... as TOTAL_COST.

swuehl
MVP
MVP

Yes, using arithmetic operator + with NULL operands will result in NULL. Use rangesum(FIELD1,FIELD2,...) instead if you want to handle NULL as zero.

Not applicable
Author

I'm Grateful..