In Google Sheets I have a list of orders recorded by order date, item, and price.
There is one order per row, but the same items are ordered on different dates and the prices vary between orders.
I'm trying to return the most recent order price for a lookup item restricted to only orders made on or before a specified date.
In the sample data below, my lookup values (batch date and item) are in the sheet "Batching log" while the lookup range is in "Orders".
Batching log (sheet 1)
batch date | item | unit price |
---|---|---|
1-feb-2024 | sand | formula |
Orders (sheet 2)
order date | Item | unit price |
---|---|---|
05-feb-2024 | sand | $2.50 |
20-jan-2024 |
sand |
$2.00 |
21-apr-2024 | stone | $32.00 |
27-oct-2023 | timber | $13.00 |
12-nov-2023 | sand | $5.00 |
28-jan-2024 | timber | $12.00 |
13-mar-2024 | stone | $35.00 |
Based on the data above, the formula in 'Batching log'!C2
should return a unit price of $2.00
This is because, of the three separate orders whose item is "sand" (rows 2, 3,and 6), row 2's date 20-jan-2024
is the most recent without exceeding the lookup date.
There are some similar questions on the site but they're different enough that I can't quite work it out.