You need to sign in to do that

Don't have an account?

Zach Ackerman

# Sum multiple fields

I wanted to create a formula to sum fields. Right now this is the formula I have.

(IF(Opportunity.UH_Covered_Lives__c:SUM> 0,Opportunity.Final_Sold_Lives__c:SUM,+IF(Opportunity.UH_Covered_Lives__c:SUM<0,Opportunity.UH_Covered_Lives__c:SUM,0)))

I am attempting to SUM Final Sold Lives (FSL) in the event UH Covered Lives (UCL) is empty and then sum that number to the instances where UCL is not empty. Right now I'm only returning the total for FSL. The below example I would expect the total to be 31 not 11.

(IF(Opportunity.UH_Covered_Lives__c:SUM> 0,Opportunity.Final_Sold_Lives__c:SUM,+IF(Opportunity.UH_Covered_Lives__c:SUM<0,Opportunity.UH_Covered_Lives__c:SUM,0)))

I am attempting to SUM Final Sold Lives (FSL) in the event UH Covered Lives (UCL) is empty and then sum that number to the instances where UCL is not empty. Right now I'm only returning the total for FSL. The below example I would expect the total to be 31 not 11.

Alain CabonHello Zack;

Nice drawing. Baquiat would have liked it.

You have written this:

IF(Opportunity.UH_Covered_Lives__c:SUM > 0THENOpportunity.Final_Sold_Lives__c:SUM

ELSE IF(Opportunity.UH_Covered_Lives__c:SUM < 0THENOpportunity.UH_Covered_Lives__c:SUM

ELSE0The following formula is logical but that could not be your need:

IF

(Opportunity.UH_Covered_Lives__c:SUM > 0,Opportunity.Final_Sold_Lives__c:SUM, 0)+IF(Opportunity.UH_Covered_Lives__c:SUM > 0,Opportunity.UH_Covered_Lives__c:SUM, 0)Alain

Zach AckermanAlain, thanks, but it seems in the event that both fields are populated it is suming those both. Example.

FSL=30 UCL=29 The total is 59 where it should 29

Zach AckermanAlain,

I think the below is a better example.

Group 1 UCL= 29 FSL=30

Group 2 UCL = 0 FSL = 30

Group 3 UCL = 50 FSL 2

In this example I would want the following to happen.

If UCL is greater than 0 use UCL

Else IF FSL is greater than 0 use FSL. Using this logic with the above i would take the following from each group.

Group 1 = 29

Group 2 = 30

Group 3 = 50

Total = 109

Currently the formula is returning the following

Group1=59

Group2=30

Group3=52

Total=141

Alain Cabon

If UCL is greater than 0 use UCLElse IF FSL is greater than 0 use FSL. Using this logic with the above i would take the following from each group.

IF(Opportunity.UH_Covered_Lives__c:SUM > 0, Opportunity.UH_Covered_Lives__c:SUM,

IF(Opportunity.Final_Sold_Lives__c:SUM > 0,Opportunity.Final_Sold_Lives__c:SUM,0))

You have solved yourself your problem writting the formula with IF and ELSE.

IF ( condition , <return value #1 if true> , < return value #2 if false> / <include new if condition > )

Alain

Zach AckermanYes, logically that works within excel, but it isn't working with the salesforce report formula. In salesforce it only counts the FSL. Alain CabonWe will have to see your report. The values are grouped by a field. What field did you choose for grouping the data into your summary report?