Help

Re: Nested If: The next upcoming date across up to 4 columns

832 1
cancel
Showing results for 
Search instead for 
Did you mean: 
Patrick_Flanaga
5 - Automation Enthusiast
5 - Automation Enthusiast

We 're a nonprofit, and we keep a database of foundations to which we plan to apply for grants. Some of them have no deadlines, while others have 1, 2, 3, or 4 deadlines per year.

We record each deadline in a separate column/field (we’re using the free version, so we can’t access the multiple dates feature), with field titles {Deadline 1}, {Deadline 2}, etc.

We now have a new field that outputs the next deadline in reader-friendly format, if there is one, based on a thorough nesting of IF() statements. Here, the statement names “IF2”, “IF3”, etc. are for keeping track of things while assembling, but the final assembly at the end just includes the conditional statements.

IF1: If Deadline 1 is blank, blank, else IF2
IF({Deadline 1}=BLANK(), BLANK(), IF2)

IF2: If Deadline 1 is after today, Deadline 1, else IF3
IF(IS_AFTER({Deadline 1}, TODAY()), DATETIME_FORMAT({Deadline 1}, 'll'), IF3)

IF3: If Deadline 2 is blank, IF9, else IF4
IF({Deadline 2}=BLANK(), IF9, IF4)

IF4: If Deadline 2 is after today, Deadline 2, else IF5
IF(IS_AFTER({Deadline 2}, TODAY()), DATETIME_FORMAT({Deadline 2}, 'll'), IF5)

IF5: If Deadline 3 is blank, IF9, else IF6
IF({Deadline 3}=BLANK(), IF9, IF6)

IF6: If Deadline 3 is after today, Deadline 3, else IF7
IF(IS_AFTER({Deadline 3}, TODAY()), DATETIME_FORMAT({Deadline 3}, 'll'), IF7)

IF7: If Deadline 4 is blank, IF9, else IF8
IF({Deadline 4}=BLANK(), IF9, IF8)

IF8: If Deadline 4 is after today, Deadline 4, else IF9
IF(IS_AFTER({Deadline 4}, TODAY()), DATETIME_FORMAT({Deadline 4}, 'll'), IF9)

IF9: If Deadline 1 is blank, blank, else Deadline 1 + 365 days
IF({Deadline 1}=BLANK(), BLANK(), DATETIME_FORMAT(DATEADD({Deadline 1}, 1, 'year'), 'll'))

Added all together:

IF({Deadline 1}=BLANK(), BLANK(),IF(IS_AFTER({Deadline 1}, TODAY()), DATETIME_FORMAT({Deadline 1}, 'll'), IF({Deadline 2}=BLANK(), IF({Deadline 1}=BLANK(), BLANK(), DATETIME_FORMAT(DATEADD({Deadline 1}, 1, 'year'), 'll')), IF(IS_AFTER({Deadline 2}, TODAY()), DATETIME_FORMAT({Deadline 2}, 'll'), IF({Deadline 3}=BLANK(), IF({Deadline 1}=BLANK(), BLANK(), DATETIME_FORMAT(DATEADD({Deadline 1}, 1, 'year'), 'll')), IF(IS_AFTER({Deadline 3}, TODAY()), DATETIME_FORMAT({Deadline 3}, 'll'),IF({Deadline 4}=BLANK(), IF({Deadline 1}=BLANK(), BLANK(), DATETIME_FORMAT(DATEADD({Deadline 1}, 1, 'year'), 'll')), IF(IS_AFTER({Deadline 4}, TODAY()), DATETIME_FORMAT({Deadline 4}, 'll'), IF({Deadline 1}=BLANK(), BLANK(), DATETIME_FORMAT(DATEADD({Deadline 1}, 1, 'year'), 'll'))))))))))

I wrote this in a text editor and copied over to the formula field. If this throws an error, the most common cause I found was the format of the apostrophes around ‘ll’.

3 Replies 3

What about having a Deadlines table linked to the Foundations table? And you could use a Rollup field with a Max formula in a date field.

We want to keep track of the next deadline for each foundation, not the last one.

For example, today is June 6, and if XYZ Foundation has deadlines of 1/1, 4/1, 7/1 and 10/1, we’d like to know that the 7/1 deadline is coming up.

Gulaya
4 - Data Explorer
4 - Data Explorer

I have a similar setup, and would be interested in knowing how to do this.