Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
ShowAll Questionssorted byDate Posted
Marco Santos

# Formula Field Date

Hi,

Could anybody help me with a formula field? Namely how I can use formula to choose the latest date for example:

a = 09/09/2013
b = 11/10/2014
c = 01/01/2010

What if 2 fields are empty how it can be handled in the formula below . This formula is working perfectly but only if all fields are populated with date:

if(a>b && a>c,a,if(b>a && b>c,b,c))

Zuinglio Lopes Ribeiro Júnior
Hello,

Check out this thread it might be useful: https://developer.salesforce.com/forums/ForumsMain?id=906F00000008wbOIAQ (https://developer.salesforce.com/forums/ForumsMain?id=906F00000008wbOIAQ" target="_blank)

Regards.

Don't forget to mark your thread as 'SOLVED' with the answer that best helps you.
Hi ,
You need to update your formula fied to take care of the condition when any of the date field is empty.

try this: if (and(a!='',b!='',c!=''),if(a>b && a>c,a,if(b>a && b>c,b,c)) , if(and(a!='',b!='',c==''),if(a>b,a,b) ,  if(and(a!='',b=='',c!=''),if(a>c,a,c) , if(and(a=='',b!='',c!=''),if(c>b,c,b) , if(and(a!='',b=='',c==''),a , if(and(a='',b!='',c==''),if(a>b,a,b)

Note: i have not checked the formula . so it is possible that u may get error(minor error like curly brackets not closed at the right position) while saving the formula.

Important :
If this is what you were looking for then please mark it as a "SOLUTION" or You can Click on the "Like" Button if this was beneficial for you.

Regards
Marco Santos
Hi,

Thanks for the responses.

if (and(a!='',b!='',c!=''),if(a>b && a>c,a,if(b>a && b>c,b,c)) , if(and(a!='',b!='',c==''),if(a>b,a,b) ,  if(and(a!='',b=='',c!=''),if(a>c,a,c) , if(and(a=='',b!='',c!=''),if(c>b,c,b) , if(and(a!='',b=='',c==''),a , if(and(a='',b!='',c==''),if(a>b,a,b)

I am slightly confuse with the above formula, could you tell me where I should close the if statement, should I close all if statement at the end?

I will be appreciate for help