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

Nested if condition to calculate negative values

Hello Qlik experts,

HaPPy Friday!

I’ve this exiting script that generates/ populates a calculated field when the base field has positive number >= 0, as below:

If(policy_type = 'DBL' and (pfl <> 'N' Or IsNull(pfl)) and premium >= 0,

                If(policy_eff< '1/1/2019' and livecount <= 50, premium * 0.75,

                                If(policy_eff< '1/1/2019' and livecount > 50, premium * 0.85, premium *0.92))) as pfl_premium,

I need to modify the nested if condition so that it also calculates for the base field’s negative values and turn into positive *-1. Below data table view may help to visualize

PFL.png

I need pfl_premium to populate 93.75 when premium is either -125 or 125 and so on. Please help when I modified the script it doesn’t give the right calculation.

Thank you very much for your help.

Labels (2)
2 Replies
martynova
Contributor II
Contributor II

Hi, did you try create new column where like this (you could do it in script and create new measure)

if(value < 0, value*-1, value)

 

And then count what you whant

mja_jami
Contributor III
Contributor III
Author

Thank you Martynova for your reply. Failed to change the script I instead created a new column to (8-1) when premium is <0 and that's my workaround for now. 
Thanks very much.