Trying to create a formula field in salesforce to calculate the average number of days taken from Close date to (either of the 2 other dates).
E.g
Close date
Email start date
live date
formula I’m trying to write is close date – (earliest of the email start date or the live date).
Help will be appreciated.
thanks
There’s a
MAX()function available but it accepts only numbers, not dates. So have a look at these and pick whichever you’re feeling more comfortable with 😉(Formula type must be of type Number, call it “Lifespan (in days)” or something)
or
Edit to incorporate Priyanka’s problem from the comments:
If you have several dates you want to fall back on (if one is null, try another one) it’s best to use
BLANKVALUEfunction to avoid long chains of IF statements:You can also combine it with the trick with IF’s to select lowest one, for example:
This will check the override date first. If it’s null but both email start & go live dates are set – will select smaller of the 2. If any of them is blank – will keep falling back to check estimated dates and finally will give up if with null if everything was null.
But I have to say if you really need to write such convoluted things – you’re doing something wrong. Force your users to start filling in some dates earlier, it’s a sign of very poor data quality…