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

Optimize if then else in expression

Hello,

i have to optimize one expression on chart :

if(sum({<Year={$(vCurrentYear)},Month={$(vCurrentMonth)},[Top]={"O"}>}[OD-Stock value]) <= sum({<Year={$(vYearBefore_MonthAfter)},Month={$(vMonthAfter)},[Top]={"O"}>}[OD-Sales]),

   sum({<Year={$(vCurrentYear)},Month={$(vCurrentMonth)},[Top]={"O"}>}[OD-Stock value])*30/sum({<Year={$(vYearBefore_MonthAfter)},Month={$(vMonthAfter)},[Top]={"O"}>}[OD-Sales]),

if(sum({<Year={$(vCurrentYear)},Month={$(vCurrentMonth)},[Top]={"O"}>}[OD-Stock value]) <= sum({<Year={$(vYearBefore_MonthAfter)},Month={$(vMonthAfter)},[Top]={"O"}>}[OD-Sales])

  +sum({<Year={$(vYearBefore_Month+2)},Month={$(vMois+2)},[Top]={"O"}>}[OD-Sales]),

((sum({<Year={$(vCurrentYear)},Month={$(vCurrentMonth)},[Top]={"O"}>}[OD-Stock value])-sum({<Year={$(vYearBefore_MonthAfter)},Month={$(vMonthAfter)},[Top]={"O"}>}[OD-Sales]))*30

/sum({<Year={$(vYearBefore_Month+2)},Month={$(vMois+2)},[Top]={"O"}>}[OD-Sales]))+30

))

I can't do this test on the script, because the value depend of selection in application.

The variables vCurrentYear, ... are calculated with the current selection.

Thanks for your suggestions.

Sophie

0 Replies