Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

SUM 2 fields on 2 conditions...

OK, I have a question re: summing. I want to SUM [Contract Value] when Stage is 'Contract' and add this to the SUM of [Pipeline Value] when Stage is 'Contract Negotiation' or 'Offer Negotiation'.

I've seen conditional sums in here, but they are typically summing one field when multiple conditions exist. Here I need to sum 2 fields when 2 or more conditions exist.

Any help would be greatly appreciated!

4 Replies
Anonymous
Not applicable
Author

Hi Try this code:

=Sum((If(Stage='Contract',ContractValue) and if(Stage='Contract Negotiation' or 'Offer Negotiation',[Pipeline Value]))

Not applicable
Author

Thanks for this!  I just had to tweak the "and" to an "or" and now it works, so I get what I need! Thanks!

Not applicable
Author

Hi James

IF want to SUM [Contract Value] when Stage is 'Contract' and add this to the SUM of [Pipeline Value] when Stage is 'Contract Negotiation' or 'Offer Negotiation'. please see below code try to with this hopefully it will work out for your issue.

=Sum((If(Stage='Contract',ContractValue) and if(Stage='Contract Negotiation' or 'Offer Negotiation',[Pipeline Value]))

qlikoqlik
Creator
Creator

Hi James

If use set analysis the syntax would as per below and sum(set analysis is more efficient than ifs

=sum({<Stage={'Contract'}>}[Contract Value])

+ sum({< Stage= {'Contract Negotiation' , 'Offer Negotiation'}>} [Pipeline Value])

Regards

Padma