Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Not applicable

Script Error ")" expected

I am getting a script error: ")" expected for this IF statement. Sure would be grateful is somebody can troubleshoot this for me. Thank you.

If TempInvoice_Sys_MR66 <>'SF' and TempHeadQuarters.NUMBER<> '999' and Invoice_EDA_Year=$(=Only(Invoice_EDA_Year)-1), TempDtl_Purchase_Amount) as ePurchasesPY

2 Replies

Re: Script Error ")" expected


I don't know if that's a typo, but you missed the opening parenthesis:

If(TempInvoice_Sys_MR66 <> 'SF' and TempHeadQuarters.NUMBER <> '999' and Invoice_EDA_Year = $(=Only(Invoice_EDA_Year)-1),

TempDtl_Purchase_Amount) as ePurchasesPY

Note that the $(=) part will cause a "internal error" although it usually keeps running the script, meaning that that part of the If() will never be tested, so I'd use instead:


     TempInvoice_Sys_MR66 <> 'SF'

     AND TempHeadQuarters.NUMBER <> '999'

     AND Invoice_EDA_Year = Invoice_EDA_Year -1, // will never match


) AS ePurchasesPY

Note as well that this third condition will never be matched, in the same record, the field Invoice_EDA_Year can only have one value, say 2012, and not two values, so Invoice_EDA_Year (2012) will never be equal to Invoice_EDA_Year -1 (2011) in the same record, because a value cannot be equal to another value. It seems that you want to do some kind of aggregation or looking for some previous values, and you got to the Only() function.

Hope that helps.


Not applicable

Re: Script Error ")" expected

Ok, thank you for your help, I will work on this.