Feb 10, 2019 07:39 AM
Hello everyone!
I have a need for a field that determines next “share time” for an event based on specific criteria.
I have the following columns:
{Start date} = date field
{End date} = date field
{Select dates} = checkbox field that indicates when an event concists of only select dates between the {Start date} and {End date} and not the whole span. I also have a date field for
{Last shared} = date field
What I want to achieve is a new field, using formula, that gives me the date the event should be shared next called {Next share}.
Idealy I would like it to additionally return the following:
I am beyond greatful for any and all help I may get as I am new to Airtable.
I am able to find my way around easier formulas, but the multiple conditions here have me stumped.
Feb 12, 2019 08:29 AM
IF(AND(DATETIME_DIFF({End date},{Start date}, ‘days’) < 14,
{Select dates} = 0,
DATETIME_DIFF({End Date}, TODAY(), ‘days’) > 0),
DATEADD({Last shared}, 7, ‘days’){Last shared},
IF(AND(DATETIME_DIFF({End date},{Start date}, ‘days’) > 14,
{Select dates} = 0,
DATETIME_DIFF({End Date}, TODAY(), ‘days’) > 0),
DATEADD({Last shared}, 14, ‘days’){Last shared},
BLANK())
)
That should sort out the first part. I personally wouldn’t use a formula that can output a date and a string, but if you must then this should work:
IF( {End date}=BLANK(), “Single Event”,IF({Select dates}=1,“Share at next occurance”,IF(AND(DATETIME_DIFF({End date},{Start date}, ‘days’) < 14,
DATETIME_DIFF({End Date}, TODAY(), ‘days’) > 0),
DATEADD({Last shared}, 7, ‘days’){Last shared},
IF(AND(DATETIME_DIFF({End date},{Start date}, ‘days’) > 14,
DATETIME_DIFF({End Date}, TODAY(), ‘days’) > 0),
DATEADD({Last shared}, 14, ‘days’){Last shared},
BLANK())
)))
I haven’t tested these, so there may be some typos.
Feb 12, 2019 01:12 PM
Thank you so much for these.
I tried 'em out and somethings off as they are and I’m honestly too tired to figure out just what right now, it’s been a looong day, but I will deffinetely have a better look in the morning and see if I can figure it out.
What are the drawbacks having the same formula return a date output and a string?
Anyway, I just really wanted to thank you for taking time to answer.
Feb 13, 2019 02:05 AM
Sorry, there were a couple of typos. These work:
IF(AND(DATETIME_DIFF({End Date},{Start Date}, “days”) < 14, {Select dates} = 0, DATETIME_DIFF({End Date}, TODAY(), “days”) < 0), DATEADD({Last shared}, 7, “days”), IF(AND(DATETIME_DIFF({End Date},{Start Date}, “days”) > 14, {Select dates} = 0, DATETIME_DIFF({End Date}, TODAY(), “days”) < 0), DATEADD({Last shared}, 14, “days”), BLANK()) )
And then:
IF( {End date}=BLANK(), “Single Event”,IF({Select dates}=1,“Share at next occurance”,IF(AND(DATETIME_DIFF({End Date},{Start Date}, “days”) < 14,
{Select dates} = 0,
DATETIME_DIFF({End Date}, TODAY(), “days”) < 0),
DATEADD({Last shared}, 7, “days”),
IF(AND(DATETIME_DIFF({End Date},{Start Date}, “days”) > 14,
{Select dates} = 0,
DATETIME_DIFF({End Date}, TODAY(), “days”) < 0),
DATEADD({Last shared}, 14, “days”),
BLANK())
)))
In general I would want the output of any formula field to be consistent. Mainly because if you want to subsequently make calculations on the data in those fields you might not be able to. Particularly if you are going to be rolling up data into another table, or even if you just wish to look at the sum or average at the bottom of the table.
A problem more specific to what you are trying to achieve here is that you cannot format the {Next share} field as a date if it can also be a string. This means that your dates will be stuck formatted in ISO format like this:
rather than this:
Feb 16, 2019 06:27 AM
Thank you again for taking time to answer and explaining to me.
Now that I understand the issue I agree that both a date and string output is less than ideal. If nothing else for the reason to avoid the pesky date formate, but the added reasons makes it a no-brainer.
When using the second version of the first formula you provided I run into the following:
Unfortunately my brain has taken a vacation due to a combination of illness and lack of propper sleep making me stare dumbly at the formula instead of being able to figure it out.
Additionally:
Since having a formula return a date and a string is a bad idea, what is the best way to work around this of the suggestions below?
Is there a way to, by in one field only log the dates the {Select event} takes place, have the next date in that series minus three days be displayed in the {Next share} field?
(As we have a free account and a lot of records, we don’t want to add to the amount of records by creating and linking a table to log the dates as I’ve seen suggested elsewhere on this forum, so the work around has to sork without adding records).
Some other genius solution that I haven’t even thought of.
If anyone has the kindness in their heart to help with any of these questions I would be beyond greatful, especially since I am currently unable to digest and apply new information to solve the problem on my own.