14 Replies Latest reply: Dec 23, 2015 10:54 AM by Sangram Reddy

# 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

• ###### 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 ))))  ;

• ###### 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

)

)

)

• ###### 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".

• ###### 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 ....

• ###### 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)

)

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

Hey Sangram Reddy ,

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,ЕВРО

\$, \$,доллар

];

• ###### 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.

• ###### 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).

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

Hey Andy Weir,

tried your script but didn't work.

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

Need more details than that if you want help on an error.  how about a screen shot of the error your getting if any?  Provide the context and people can help you out better.

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

Hey Sangram Reddy  ,

i took your advice and defined EnCurrency  as dimension but didn't work....

• ###### 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!

Try using a bar chart to test the expression!

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

Here is a snapshot

Here is a link to the original file

clinton key table7.qvf - Google Drive

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

Left a , in.  This should work without an error

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)

)