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

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
johnmaclain789
Contributor
Contributor

How can this syntax be improved?

Greetings to all!
Could you please tell me where the problem is with this syntax? Thank you so much, please accept my sincere gratitude
When ISPROJECTMAINORDER = '-1'
AND
ordercategory_code = '100'
AND
(sum(Total_cost_price_pbd) > 0.0), Total_cost_price_pbd,


(ISPROJECTMAINORDER = '-1'
AND
ordercategory_code = '100', TOTALNETAMOUNT * 0.65,
sum(SO_costprice)))

Labels (1)
2 Replies
vinieme12
Champion III
Champion III

is this an interview question ? there is another post regarding this!!

 

 

https://community.qlik.com/t5/New-to-Qlik-Sense/Could-you-please-explain-what-s-wrong-with-this-synt...

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
justISO
Specialist
Specialist

Hi, it depends on where you want to use this expression. If it is in load script when loading data, it probably should go with prefix WHERE, not WHEN, and all sum functions should be covered with flags.

If it is in report level, if() function is best in this case, and you expression could look like this:

if(ISPROJECTMAINORDER = '-1' and ordercategory_code = '100' and (sum(Total_cost_price_pbd) > 0) , sum(Total_cost_price_pbd),
if(ISPROJECTMAINORDER = '-1' and ordercategory_code = '100', sum(TOTALNETAMOUNT * 0.65), sum(SO_costprice)))