Save the date! Join us on October 16 for our Product Ops launch event. Register here.
Jun 30, 2022 08:22 AM
Hi. I’m looking to track how much time (in days) a lead spends in each stage in a pipeline. I’m basing it on start and stop dates of time in stage. The formula I’m trying to accomplish is this (hope it makes sense):
Is the start date blank?
I came up with the following but I just get an error that the formula isn’t correct.
IF({Start Date} = BLANK(), “”, IF({End Date} = BLANK(), DATETIME_DIFF(TODAY(),{Start Date}, ‘days’), DATETIME_DIFF({End Date}, {Start Date}, ‘days’)
What’s not working?!
Definitely new to AirTable and formulas in general so if there is another way to approach this, I’m all ears! :). Thanks!
Solved! Go to Solution.
Jun 30, 2022 08:52 AM
The rest of your formula is a mathematic function that should result in a number, but your first condition results in an empty string.
In Airtable, you want to say “If field is blank do nothing”, you get the same result as “Do something if the field has a value” without risking putting strings where numbers/dates should be.
The other issue with your formula is its missing closing parentheses for the first IF.
IF(
{Start Date},
DATETIME_DIFF(
IF({End Date}, {End Date}, TODAY()),
{Start Date},
'days'
)
)
Since the DATETIME_DIFF function’s only variable was the first date, I just used the function once with an IF inside it.
Jun 30, 2022 08:52 AM
The rest of your formula is a mathematic function that should result in a number, but your first condition results in an empty string.
In Airtable, you want to say “If field is blank do nothing”, you get the same result as “Do something if the field has a value” without risking putting strings where numbers/dates should be.
The other issue with your formula is its missing closing parentheses for the first IF.
IF(
{Start Date},
DATETIME_DIFF(
IF({End Date}, {End Date}, TODAY()),
{Start Date},
'days'
)
)
Since the DATETIME_DIFF function’s only variable was the first date, I just used the function once with an IF inside it.
Jun 30, 2022 08:59 AM
This works perfect. I’ll study and keep in mind for the future. Thank you!
Jun 30, 2022 09:04 AM
I tend to simplify formulas down as much as possible. If you’re curious, the correct syntax for your original method would be:
IF(
{Start Date} = BLANK(),
BLANK(),
IF(
{End Date} = BLANK(),
DATETIME_DIFF(TODAY(),{Start Date}, 'days'),
DATETIME_DIFF({End Date}, {Start Date}, 'days')
)
)
Jul 01, 2022 12:30 PM
Yeah. This is a thing of beauty!