Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Highlighted
mja_jami
New 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 (4)
2 Replies
martynova
New Contributor

Re: Nested if condition to calculate negative values

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
New Contributor III

Re: Nested if condition to calculate negative values

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.