Search code examples
google-sheetsgoogle-sheets-formulainventory-management

Google Sheets: Index and Match - Find the dated column greater than today that has a value for a specific row


Given the set below:

enter image description here

  • A2 is =today(), resolving to the date value of Apr-19
  • range D2:2 (D2 and onwards to the right) are a list of dates
  • A4 is a product that im expecting to be shipped
  • range D4:4 (D4 and onwards to the right) are the number of units of A4 im expecting to arrive by their corresponding date on row D2:AH
  • The sample is simplified but row 4 downwards is dynamic and I can have more items on that table

I need:

  • Cell B4 to return the value from range D4:4 of the latest date that's more than A2 (today)

Samples:

  • A2 = Apr 19, then B4 = 130 (from Apr 23)
  • A2 = Apr 22, then B4 = 130 (from Apr 23)
  • A2 = Apr 23, then B4 = 0 (from Apr 24)

I tried using INDEX and MATCH but I can't get the "Greater than today" part for match.

Thanks in advance.


Solution

  • I managed to get what I needed by combining CHOOSEROWS, TOCOL, and FILTER from this answer and harun24hr's answer.

    Here it is in action: =CHOOSEROWS(TOCOL(FILTER(D4:4,D$2:$2>A$2),1),-1)

    enter image description here