Tai McLaughlin
Tai McLaughlin

Reputation: 3

How do I make one column return a desired value based on the date in another column?

I'm looking for a formula that will automatically return a value based on the date entered in another column.

Here is a photo copy of the spreadsheet with desired results.

Here is a photo copy of the spreadsheet with desired results. Essentially, I want the number 0,1,2,3 to be returned automatically based on the data entered in column F, which are dates.

Ex.

I'm having trouble fitting all of the conditions required into a formula and I've had embarrassingly low levels of success with this. To be frank, I'm not even sure anymore what kind of function should be used for what I'm trying to accomplish. Any help that could be offered would be greatly appreciated.

Upvotes: 0

Views: 117

Answers (2)

Stormwaker
Stormwaker

Reputation: 391

I'm no Google Sheets expert, but maybe something like this:

=IFS(A1 = DATEVALUE("1/1/2020"), 0, A1 = "", 1, AND(A1 > DATEVALUE("01/01/2020"), A1 < DATEVALUE("01/01/2021")), 3, A1 < DATEVALUE("01/01/2019"), 2)

Replace A1 with input field.

Upvotes: 0

oshliaer
oshliaer

Reputation: 4979

You can try something like this

=ARRAYFORMULA(
  (F2:F=DATE(2021,1,1))*1+
  (F2:F="")*2+
  (F2:F<DATE(2019,1,1))*(ISDATE_STRICT(F2:F))*3+
  (F2:F>=DATE(2020,1,1))*(F2:F<DATE(2021,1,1))*4+
  -1
)

enter image description here

Upvotes: 2

Related Questions