Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

Announcements
Qlik® Product Spotlight: Discover what’s possible. Get more from our products.
See for yourself. Register today.
Not applicable

If statement that for some reason doesn't work

Hey Everyone ,

I am trying to run the following IF statement :

IF(EnCurrency='NIS',Num(sum( {$< TRANS_TYPE = {N}>}  NIS_TRANS_TOTPRICE  )* -1,

IF(EnCurrency='$',Num(sum( {$< TRANS_TYPE = {N}>}  DOLLAR_TRANS_TOTPRICE )* -1,

IF(EnCurrency='EUR',Num(sum(  {$< TRANS_TYPE = {N}>}  CURRENCY_TRANS_TOTPRICE)* -1 ))))  ;

EnCurrency= CURRENCY

for some reason this If statment doesn't

1 Solution

Accepted Solutions
reddys310
Honored Contributor II

Re: If statement that for some reason doesn't work

Hi Jhonatan,

I tried plotting the dimension "EnCurrency" and the measure with the expression:

IF(EnCurrency='NIS', Sum( {$< TRANS_TYPE = {N}>}  NIS_TRANS_TOTPRICE  )* -1,

     IF(EnCurrency='$', Sum( {$< TRANS_TYPE = {N}>}  DOLLAR_TRANS_TOTPRICE )* -1,

          IF(EnCurrency='EUR', Sum(  {$< TRANS_TYPE = {N}>}  CURRENCY_TRANS_TOTPRICE)* -1

           )

     )

)

Works absolutely fine!

Capture.PNG

Try using a bar chart to test the expression!

14 Replies
Chanty4u
Esteemed Contributor III

Re: If statement that for some reason doesn't work

IF(EnCurrency='NIS',Num(sum( {$< [TRANS_TYPE ]= {'N'}>}  NIS_TRANS_TOTPRICE  )* -1,

IF(EnCurrency='$',Num(sum( {$< [TRANS_TYPE] = {'N'}>}  DOLLAR_TRANS_TOTPRICE )* -1,

IF(EnCurrency='EUR',Num(sum(  {$< [TRANS_TYPE ]= {'N'}>}  CURRENCY_TRANS_TOTPRICE)* -1 ))))  ;

MVP
MVP

Re: If statement that for some reason doesn't work

In which context are you trying to use this statement? In the script or in a chart? If it's in a chart, what are the chart dimensions?

Besides that, I think the syntax is not valid, double check the opening and closing brackets.

IF(EnCurrency='NIS', Sum( {$< TRANS_TYPE = {N}>}  NIS_TRANS_TOTPRICE  )* -1,

     IF(EnCurrency='$', Sum( {$< TRANS_TYPE = {N}>}  DOLLAR_TRANS_TOTPRICE )* -1,

          IF(EnCurrency='EUR', Sum(  {$< TRANS_TYPE = {N}>}  CURRENCY_TRANS_TOTPRICE)* -1

           )

     )

)

reddys310
Honored Contributor II

Re: If statement that for some reason doesn't work

Hi Jhonatan,

If this condition is in the script it wont work at all, but if its in the UI side as an expression, make sure that one of the dimensions is "EnCurrency".

Not applicable

Re: If statement that for some reason doesn't work

Hey Swuhel

i am trying to use this is as shippment returns caculation,

NIS = means New Isareli Shekel ( Israeliy coin) name.

EnCurrency = type of  CURRENCY.

i tried to run the script you wrote down and didn't work ....

ogster1974
Honored Contributor II

Re: If statement that for some reason doesn't work

Why don't you try this.  It will perform better than a nested if statement to...

pick(match(EnCurrency,'NIS','$','EUR'),

// NIS

, Num(sum( {$< TRANS_TYPE = {N}>}  NIS_TRANS_TOTPRICE  )* -1)

//

, Num(sum( {$< TRANS_TYPE = {N}>}  DOLLAR_TRANS_TOTPRICE )* -1)

// EUR

, Num(sum(  {$< TRANS_TYPE = {N}>}  CURRENCY_TRANS_TOTPRICE)* -1)

)

Not applicable

Re: If statement that for some reason doesn't work

Hey Reddys310 ,

i defined it as a Measure on my report,

and in the script i have defined the EnCurrency  on the script:

CURRENCY_TABLE:

LOAD * INLINE [

    Currency,EnCurrency,Rcurrency

    ₪, NIS,сикель

    €, EUR,ЕВРО

    $, $,доллар

];

reddys310
Honored Contributor II

Re: If statement that for some reason doesn't work

Hi Jhonatan,

Is EnCurrency one of the dimmensions in your visualization? If not you need to have that as a dimmension to make the expression work.

Not applicable

Re: If statement that for some reason doesn't work

Hey Ogster1974,

tried your script but didn't work.

MVP
MVP

Re: If statement that for some reason doesn't work

Or you need to select exactely one value from field EnCurrency (or from fields Currency, Rcurrency).

Community Browser