Value Extraction

Steve 1962

Active Member
Joined
Jan 3, 2006
Messages
382
Office Version
  1. 365
Platform
  1. Windows
Hi
I have a list of dates & values (columns D & E). I have lookup values (column A) that refer to the dates in the list and values are extracted from column E, according to the lookup date.

The problem I have is that not all dates in column D are consecutive. In the example, there is no 25/1/25 in the list in column D.

The solution that I need is that if the date does not exist in column D, then give the value from column E that is closest to the Lookup Date in column A (preceding closet value). In this case, the extracted value would be $52,466 (associated with 24/1/25). Formulas needed in column B.

Thanks
S

Book1
ABCDE
1Lookup DateValueDate1List
214/01/2025$54,31910/01/2025$54,305
325/01/2025$52,46613/01/2025$54,312
411/02/2025$25,11114/01/2025$54,319
515/01/2025$54,341
616/01/2025$54,349
717/01/2025$54,356
820/01/2025$54,363
921/01/2025$54,371
1022/01/2025$54,392
1123/01/2025$54,400
1224/01/2025$52,466
1328/01/2025$52,473
1429/01/2025$52,480
1530/01/2025$52,508
1631/01/2025$52,515
173/02/2025$52,522
184/02/2025$52,529
195/02/2025$52,550
206/02/2025$52,557
217/02/2025$50,620
2210/02/2025$65,222
2311/02/2025$25,111
2412/02/2025$35,222
2513/02/2025$65,412
Sheet1
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
lookup with specific nearest date less/more, try :

Excel Formula:
=LET(dt,A2,DD,$D$1:$D$100,EE,$E$1:$E$100,a,XLOOKUP(dt,DD,DD,,1),b,XLOOKUP(dt,DD,DD,,-1),XLOOKUP(dt+MIN(a-dt,b-dt),DD,EE))
 
Upvote 0
if the date does not exist in column D, then give the value from column E that is closest to the Lookup Date in column A (preceding closet value).
try

Excel Formula:
=XLOOKUP(A2,D:D,E:E,XLOOKUP(A2,D:D,E:E,,-1))
There is no need for a double XLOOKUP to achieve the request.

25 02 13.xlsm
ABCDE
1Lookup DateValueDate1List
214/01/2025$54,31910/01/2025$54,305
325/01/2025$52,46613/01/2025$54,312
411/02/2025$25,11114/01/2025$54,319
515/01/2025$54,341
616/01/2025$54,349
717/01/2025$54,356
820/01/2025$54,363
921/01/2025$54,371
1022/01/2025$54,392
1123/01/2025$54,400
1224/01/2025$52,466
1328/01/2025$52,473
1429/01/2025$52,480
1530/01/2025$52,508
1631/01/2025$52,515
173/02/2025$52,522
184/02/2025$52,529
195/02/2025$52,550
206/02/2025$52,557
217/02/2025$50,620
2210/02/2025$65,222
2311/02/2025$25,111
2412/02/2025$35,222
2513/02/2025$65,412
XLOOKUP
Cell Formulas
RangeFormula
B2:B4B2=XLOOKUP(A2,D:D,E:E,,-1)
 
Upvote 0
Solution
thanks for advice, I have a concern, so I locked the first lookup with a matching value.
 
Upvote 0
Thanks Peter. I have amended as per your recommendation and it works fine.

Appreciate your time.

Steve
 
Upvote 0
You're welcome. Thanks for the follow-up. :)

BTW, you could do them all at once without copying the formula down

25 02 13.xlsm
ABCDE
1Lookup DateValueDate1List
214/01/2025$54,31910/01/2025$54,305
325/01/2025$52,46613/01/2025$54,312
411/02/2025$25,11114/01/2025$54,319
515/01/2025$54,341
616/01/2025$54,349
717/01/2025$54,356
820/01/2025$54,363
921/01/2025$54,371
1022/01/2025$54,392
1123/01/2025$54,400
1224/01/2025$52,466
1328/01/2025$52,473
1429/01/2025$52,480
1530/01/2025$52,508
1631/01/2025$52,515
173/02/2025$52,522
184/02/2025$52,529
195/02/2025$52,550
206/02/2025$52,557
217/02/2025$50,620
2210/02/2025$65,222
2311/02/2025$25,111
2412/02/2025$35,222
2513/02/2025$65,412
XLOOKUP
Cell Formulas
RangeFormula
B2:B4B2=XLOOKUP(A2:A4,D:D,E:E,,-1)
Dynamic array formulas.
 
Upvote 0

Forum statistics

Threads
1,226,525
Messages
6,191,566
Members
453,665
Latest member
WaterWorks

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top