Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Aika
Contributor III
Contributor III

error "Error in expression: ')'

I have the following statement that don't works in my load script:

-1 * sum(
CASE WHEN amount <0 AND transaction_type_code = 'cashin' THEN amount
WHEN amount >0 AND transaction_type_code = 'revert' THEN amount
ELSE 0
END
)

However when I do this I get the error "Error in expression: ')' expected". Is there a way to fix this?

2 Replies
Or
MVP
MVP

This statement looks like it's SQL. It won't work in Qlik load statements because it's not valid Qlik syntax. Qlik does have a CASE statement but it works differently (and is used for different use cases): https://help.qlik.com/en-US/qlikview/April2019/Subsystems/Client/Content/QV_QlikView/Scripting/Scrip...

You can do this calculation in your SQL query and load the result if that's feasible. Alternatively, you can re-write your statement using Qlik syntax, for example with something along the lines of (note: not necessarily correct syntax since I'm not able to test it):

-1 * (sum(

if(amount <0 AND transaction_type_code = 'cashin',amount,

if(amount >0 AND transaction_type_code = 'revert',amount,

0))

))

Aika
Contributor III
Contributor III
Author

thanks, it seems to work!