3 Replies Latest reply: Mar 16, 2017 6:43 AM by Praveena Sarabhu

# Optimized approach for nested IF statement

Hi All,

Am using the below expression in my dashboard for some background change of an extension in qliksense.

if(sum({<[ID]={'6'}>}value)=0

or sum({<[ID]={'9'}>}value)=0

or sum({<[ID]={'8'}>}value)=0

or sum({<[ID]={'7'}>}value)=0

or sum({<[ ID]={'3'}>}value)=0

or isnull(\$(Vscrvalue1))=-1, '#d3d3d3',

if(sum({<[ID]={'6'}>}value)<>0

and sum({<[ID]={'9'}>}value)<>0

and sum({<[ID]={'8'}>}value)<>0

and sum({<[ID]={'7'}>}value)<>0

and sum({<[ID]={'3'}>}value)<>0

and \$(Vscrvalue1) >=only({<MId = {1}>}Upper_Bound),'#46c646',

if(sum({<[ID]={'6'}>}value)<>0

and sum({<[ID]={'9'}>}value)<>0

and sum({<[ID]={'8'}>}value)<>0

and sum({<[ ID]={'7'}>}value)<>0

and sum({<[ID]={'3'}>}value)<>0

and \$(Vscrvalue1) < only({<MId = {1}>}Upper_Bound)

and \$(Vscrvalue1)>only({<MId = {1}>}Lower_Bound), '#FFF400',

if(sum({<[ID]={'6'}>}value)<>0

and sum({<[ID]={'9'}>}value)<>0

and sum({<[ID]={'8'}>}value)<>0

and sum({<[ ID]={'7'}>}value)<>0

and sum({<[ ID]={'3'}>}value)<>0

and \$(Vscrvalue1) < only({<MId = {1}>}Lower_Bound),'#ee5a35',))))

Can you provide a better, fast and optimized way to achieve this?

Thanks,

Praveena Kumar

• ###### Re: Optimized approach for nested IF statement

Hi All,

Can someone provide a solution to the above?

• ###### Re: Optimized approach for nested IF statement

Maybe this:

If(RangeMin(

fabs(Sum({<[ID] = {'6'}>} value)),

fabs(Sum({<[ID] = {'9'}>} value)),

fabs(Sum({<[ID] = {'8'}>} value)),

fabs(Sum({<[ID] ={'7'}>} value)),

fabs(Sum({<[ID] = {'3'}>} value))) > 0,

If(\$(Vscrvalue1) >= Only({<MId = {1}>}Upper_Bound),'#46c646',

If(\$(Vscrvalue1) < Only({<MId = {1}>}Upper_Bound) and \$(Vscrvalue1) > Only({<MId = {1}>}Lower_Bound), '#FFF400',

If(\$(Vscrvalue1) < only({<MId = {1}>}Lower_Bound),'#ee5a35'))),

If(

RangeMin(

fabs(Sum({<[ID] = {'6'}>} value)),

fabs(Sum({<[ID] = {'9'}>} value)),

fabs(Sum({<[ID] = {'8'}>} value)),

fabs(Sum({<[ID] ={'7'}>} value)),

fabs(Sum({<[ID] = {'3'}>} value))) = 0 or isnull(\$(Vscrvalue1))=-1, '#d3d3d3'))