Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Problems with if statement in load script

Hello,

due to Performance reasons I am trying to move some expressions into the load script. Somehow I always encounter issues with the if Statement. In my qvw file I use the following Set Analysis Expresssion which works perfectly fine:

round(aggr(sum( {$<ProductionKey={'Prod'}>}ProductionQty),ProductionSegmentID),0.01)

now I am trying to do the same in the load script with an if Statement:

Load

ProductionSegmentID,

if(ProductionKey = 'Prod',round(sum(ProductionQty),0.01)) as ProductionSegmentQuantity

resident Data Group by ProductionSegmentID;

Any ideas what I´m doing wrong would be highly appreciated.

Thanks

Stefan

1 Solution

Accepted Solutions
sunny_talwar

Try this

LOAD ProductionSegmentID,

    Round(Sum(If(ProductionKey = 'Prod', ProductionQty)),0.01) as ProductionSegmentQuantity

Resident Data

Group by ProductionSegmentID;

View solution in original post

4 Replies
sunny_talwar

Try this

LOAD ProductionSegmentID,

    Round(Sum(If(ProductionKey = 'Prod', ProductionQty)),0.01) as ProductionSegmentQuantity

Resident Data

Group by ProductionSegmentID;

marcus_sommer

A different approach might be:

Load

ProductionSegmentID,

round(sum(ProductionQty),0.01) as ProductionSegmentQuantity

resident Data where ProductionKey = 'Prod' Group by ProductionSegmentID;

- Marcus

Not applicable
Author

Hello Sunny,

thanks a lot for the Help. SOmetimes you just don´t see the tree even though you are in the forest

Regards

Stefan

Not applicable
Author

Hello Marcus,

thanks for the Input. The Where Statement won´t work in this case, because some rows which I also Need in the table are not flagged as ProductionKey = Prod.

Regards

Stefan