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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

If statement variables

Hello,
I'm having issues with a few variables in my script. I actually get values, but I'm not getting the right numbers. And when I run the debugger, it errors, but doesn't give me any details.

Is my syntax right?

SET vBillRate = IF(ProjectType = 1, IF(TransType = 'TS',sum(BillRate), sum(UnitCost)),sum(FP_LineItemRevRecognized/quantity))

SET vRecRevenue  = IF(ProjectType = 1, sum(Acrev),sum(FP_LineItemRevRecognized));

SET vCompRevenue= IF(ProjectType = 1,IF(billType = 1,sum(BillRate * quantity),sum(FPRate * quantity)),sum(FPRate * quantity));

SET vRevenueDiff = $(vRecRevenue)-$(vCompRevenue);

3 Replies
CELAMBARASAN
Partner - Champion
Partner - Champion

Hi,

you cannot use Aggregation functions and field names in to asign to a variable.

pljsoftware
Creator III
Creator III

Hi Alex,

SET instruction its used to set a variable as a rock, if you wanto "ABC" you make SET var = 'ABC';

If you want a result of an expression for example A*B*C you must to use LET var = A*B*C;

In your expression you have missed a ";" before of secont SET

SET vBillRate = IF(ProjectType = 1, IF(TransType = 'TS',sum(BillRate), sum(UnitCost)),sum(FP_LineItemRevRecognized/quantity)) ;

I hope this help you.

Regards

Luca Jonathan Panetta

PLJ Software

Not applicable
Author

If I can’t use aggregation here. How should I handle this scenario? I’m a little confused on how I should handle this. Also, even when I put this expression into a chart, I don't get the correct answer. I have to add 2 different id's for the calculation to work.

Please see this thread for more details. http://community.qlik.com/message/292523#292523

Thanks,

Alex Peasley

Business Intelligence Architect

Core BTS

608-661-7769