I am new to Salesforce and need to know if I am reading this Formula correctly. Am I correct?

IF( CloseDate  =  Account.npo02__FirstCloseDate__c, "New",
IF( Account.npo02__OppAmountLastYear__c > 0, "Renewal",
IF( AND(Account.npo02__OppAmountLastYear__c = 0,        
Account.npo02__TotalOppAmount__c > 0), "Lapsed", "New")))

I believe it is saying that:

  1. If this is the first close date, then it is classed as "new".

  2. If the total opportunity last year is greater than zero it is classed "renewal".

  3. If the total opportunity last year is nothing AND the total opportunity is greater than nothing the it is true that the class is "lapsed" but it is false that the class is "new".

Your reading is correct, though I think a better reading would be:

1) If the current CloseDate is equal to the FirstCloseDate__c of the associated Account record, then the formula returns New

else, 2) If the associated Account record's OppAmountLastYear__c is greater than 0 then the formula returns Renewal

else, 3) If the associated Account record's OppAmountLastYear__c is equal to 0 and the associated Account record's TotalOppAmount__c is greater than 0 then the formula returns Lapsed

else, the formula returns New

Admittedly, from a purely business perspective, it looks as if the last clause has the symbols reversed. I'd think an Account is lapsed if last year had >0 but nothing this year. But I don't know your business case so I might be mis-reading your intent.

  • Thanks for this comment. The meaning of "lapsed" in this case means nothing was give in the last two years, so technically this is correct. – raisl Oct 17 '17 at 0:52
  • Excellent. Glad to have helped. – Sebastian Kessel Oct 17 '17 at 0:53
  • @raisl Also, you need to understand that in 1) if the CloseDate is equal to the FirstCloseDate__c, then the formula will not check 2) and 3) conditions. – sfdcFanBoy Oct 17 '17 at 3:10
  • I think that doesn't pose any danger to the business logic here as the "new" category will simply mean that it is an initial donation within one account. The only danger I see is if the donor where removed from the system and then the re-entered. Technically this wouldn't be accurate. – raisl Oct 17 '17 at 17:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.