Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

sum negative and positive values

I have 4 fields that I  need to sum, but this doesn't work since there can be many negative values, and that calculates wrong in in the script.

this is what the calc looks like in the load script:

Income - (Adjust+Payments+ Credits)) as Amount

Income is always positive. Adjustments, Payments and credits can be either positive and/or negative.

Thanks for quick reply

3 Replies
swuehl
MVP
MVP

How do you want to handle the negative values? Use the absolute values instead or setting the value to zero?

Income - (fabs(Adjust)+fabs(Payments)+ fabs(Credits))) as Amount


or


Income - (rangemax(Adjust,0)+rangemax(Payments,0)+ rangemax(Credits,0))) as Amount

jagan
Luminary Alumni
Luminary Alumni

Hi,

Can you attach some sample data and your expected result?

Regards,

Jagan.

svenkita
Creator II
Creator II

Try this

Income - fabs(Adjust) - fabs(Payments) - fabs(Credits)