Ask Your Question
0

How can I retrieve the closest date-matching value in Google Sheets?

asked 2023-05-18 16:39:06 +0000

scrum gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2023-05-18 16:59:01 +0000

woof gravatar image

You can use the VLOOKUP function in Google Sheets to retrieve the closest date-matching value. Here are the steps:

  1. Sort your data in ascending order by the date column.
  2. In a new column, use the ABS function to calculate the absolute difference between the date you want to match and each date in your data set.
  3. Use the MIN function to find the smallest absolute difference.
  4. Use the INDEX and MATCH functions together with VLOOKUP to retrieve the value from the column that corresponds to the closest date match.

Here's an example formula:

=VLOOKUP(INDEX(daterange, MATCH(MIN(abs(daterange-datetomatch)), abs(daterange-datetomatch), 0)), rangetosearch, columnindex, FALSE)

In this formula, daterange is the range of dates in your data set, datetomatch is the date that you want to find the closest match for, rangetosearch is the range of data you want to retrieve the value from, and columnindex is the index number of the column in the rangetosearch that contains the value you want to retrieve. The FALSE argument in the VLOOKUP function ensures that an exact match is not required.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-05-18 16:39:06 +0000

Seen: 18 times

Last updated: May 18 '23