Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
karensmith
Contributor II
Contributor II

script if statment

Trying to use this statement in my load script. I would like to calculate value in script using two different prices * qty, rather doing calculation in chart object. I keep getting invalid expression errors.

duty code

Orig_Sales_Price

Req_qty

Local_Sales_prices

are all fields

if (DUTY_CODE = 'M', sum((ORIG_SALES_PRICE) * (REQ_QTY)), sum((LOCAL_SALES_PRICE) * (REQ_QTY))) as BKLGVALUE

Please advise if this possible. The syntax works in fine in chart object, but performance is affected.



1 Solution

Accepted Solutions
Not applicable

Hi,

When you use SUM in your load script you have to add a GROUP BY clause as well. I suppose this it what you are looking for:

if (DUTY_CODE = 'M', ORIG_SALES_PRICE * REQ_QTY, LOCAL_SALES_PRICE * REQ_QTY) as BKLGVALUE

This way you will have price*qty per row. Now you can SUM(BKLGVALUE) in your chart.

Regards

View solution in original post

4 Replies
Not applicable

Hi,

When you use SUM in your load script you have to add a GROUP BY clause as well. I suppose this it what you are looking for:

if (DUTY_CODE = 'M', ORIG_SALES_PRICE * REQ_QTY, LOCAL_SALES_PRICE * REQ_QTY) as BKLGVALUE

This way you will have price*qty per row. Now you can SUM(BKLGVALUE) in your chart.

Regards

karensmith
Contributor II
Contributor II
Author

I'm loading my application from a qvd file? Group by works with QVD?

Not applicable

Hi,

Yes, GROUP BY works with QVD, but you don't need it. You can simply use what I have given you above. Maybe I didn't communicate properly. GROUP BY was just some background information.

karensmith
Contributor II
Contributor II
Author

Thanks wernbrenk....I really appreciate your assistance.