function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Derek RainesDerek Raines 

Formula Field: Lesser of 2 Values

Hey all!

I'm looking to create a formula field that evaluates 2 Currency fields (Let's call them A & B), selects the lower of the 2 values and pushes it to a 3rd currency field (C).

If either A or B is Null, it will push the only available option to C. How would I go about doing this? Thanks!

Steven NsubugaSteven Nsubuga
C should be a formula type field. Use this as the formula syntax 
IF (A__c == null && B__c == null, 0,
	IF (A__c == null && B__c != null, B__c,
		IF (B__c == null && A__c != null, A__c,
			IF (B__c < A__c , B__c, A__c
			)
		)
	)
)
njmcdirect officialnjmcdirect official
NJMCDirect (https://njmc-direct.us/): Such people are rare who can resist the temptation of speeding on a highway. Similarly, you have inevitably been in a situation where you parked the car at a wrong place.
 
Alain CabonAlain Cabon
Hi,

Use ISBLANK instead of ISNULL in new formulas. ISBLANK has the same functionality as ISNULL, but also supports text fields. Salesforce will continue to support ISNULL, so you do not need to change any existing formulas.
 
IF (ISBLANK(A__c) && ISBLANK(B__c), 0, 
    IF (ISBLANK(A__c) && NOT(ISBLANK(B__c)), B__c,
        IF (NOT(ISBLANK(A__c)) && ISBLANK(B__c), A__c,
            IF (B__c < A__c , B__c, A__c )
        )
    )
)
Don't forget to choose : Treat blank fields as blanks (below the formula)

User-added image
 
njmcdirect Ticketnjmcdirect Ticket
NJMCDirect (https://njmcdirect.services/) : This is working for me. Surprisingly, I have tried many ways but this one seems to be the best from all of them. When we execute two currency then we should follow the algorithm differently for each of them.