 Help between Notion users

It's free & easy

Receive points, vote and give the solution

1vote

# How to combine 'Ifempty' and 'max timestamp' formula

Hello,
I previously posted the following problem:

I have a Notion formula that pulls out the max date(the last date) from two columns, however the formula does not work unless both columns have an entry. I still need the formula to work if one of the columns has a date. What can I add to make this work?

I received the following formula that worked

``if(empty(prop("Last Date Used - Across All Verticals")), prop("Last Date Used (Historical - Manually Entered)"), if(empty(prop("Last Date Used (Historical - Manually Entered)")), prop("Last Date Used - Across All Verticals"), fromTimestamp(max(timestamp(prop("Last Date Used - Across All Verticals")), timestamp(prop("Last Date Used (Historical - Manually Entered)"))))))``

I am however running into a similar issue. I can’t seem to tweak the formula to work with multiple Notion columns (not just two). I currently have 5 date columns, and I want the formula to pull out the max date between 2 or more columns OR provide a date if just one of the columns is filled.

Current formula:

``fromTimestamp(max(timestamp(prop("Date 1")), timestamp(prop("Date 2")), timestamp(prop("Date 3")), timestamp(prop("Date 4")), timestamp(prop("Date 5"))))``

How do I add an If(empty statement to have the formula still pull out a date, when all of the columns don’t have an entry.

### Dennismel12 commented Oct 31, 2022

I came up with the below formula, that formula column accepted, but the logic doesn't seem to work unfortunately, since the column isn't populating anything.

``if(empty(prop("Date 1")), prop("Date 2"), if(empty(prop("Date 2")), prop("Date 3"), if(empty(prop("Date 3")), prop("Date 4"), if(empty(prop("Date 4")), prop("Date 5"), if(empty(prop("Date 5")), prop("Date 1"), fromTimestamp(max(timestamp(prop("Date 1")), timestamp(prop("Date 2")), timestamp(prop("Date 5")), timestamp(prop("Date 4")), timestamp(prop("Date 3")))))))))``

0vote

I think this is what you're looking for? Unsure what you want to show if all dates are empty. I defaulted to showing today's date.

``if(prop("Dates?") == 2, fromTimestamp(max(timestamp(prop("Date 1")), timestamp(prop("Date 2")), timestamp(prop("Date 3")), timestamp(prop("Date 4")), timestamp(prop("Date 5")))), if(prop("Dates?") == 1, now(), fromTimestamp(max(if(empty(prop("Date 1")), timestamp(prop("Date 1A")), timestamp(prop("Date 1"))), if(empty(prop("Date 2")), timestamp(prop("Date 2A")), timestamp(prop("Date 2"))), if(empty(prop("Date 3")), timestamp(prop("Date 3A")), timestamp(prop("Date 3"))), if(empty(prop("Date 4")), timestamp(prop("Date 4A")), timestamp(prop("Date 4"))), if(empty(prop("Date 5")), timestamp(prop("Date 5A")), timestamp(prop("Date 5")))))))``

Check out how I did this in the below page. I broke the formula down so you can improve your formula writing in the future when struggling with complex logic like this :)

https://involvedesign.notion.site/Determine-max-date-from-multiple-date-fields-57536b01132046478d45d2677e500f8e

### Dennismel12 commented Jan 10

Thank you very much Adam!! This is perfect.