two way index match with approximate date match

Kmitchell

Active Member
Joined
Feb 27, 2007
Messages
365
Office Version
  1. 365
Platform
  1. Windows
Having difficulty with setting up this formula to work properly. Essentially I need to match on row (Model) and approximate date.

In this example, Model A's closest date to 3/31/2023 is 3/30/2023 and the return value should be 87,800. I tried the below formula but its not working. Any suggestions are greatly appreciated.

NDEX($B$2:$K$15,MATCH($A22,IF($B$1:$K$1=B$21,$A$2:$A$15,1)))
 

Attachments

  • Capture.PNG
    Capture.PNG
    40 KB · Views: 27

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
What version of Excel are you using?

I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

Also your expected answer do not match your data.
 
Upvote 0
Here is the revised expected results
 

Attachments

  • Capture.PNG
    Capture.PNG
    39.6 KB · Views: 21
  • Capture.PNG
    Capture.PNG
    39.6 KB · Views: 16
Upvote 0
I think this aught to work with an older version of excel if that is what you have.

MrExcelPlayground17.xlsx
ABCDEFGHIJKL
1DateABCDEFGHIJK
23/1/2023267,00094,000220,000266,000275,00043,000400,00084,00069,000448,000446,000
33/29/2023264,000330,00036,000178,000363,000221,000165,000475,000457,000113,000391,000
43/30/2023359,000220,000368,000247,0002,000343,000388,000198,000379,00077,00090,000
53/31/2023476,000348,000455,000488,00059,00023,00082,000462,000316,000406,000422,000
64/1/2023275,00071,000388,000475,000266,000366,000214,000339,000113,00097,000411,000
74/6/2023171,000193,000290,00032,000335,000262,00031,00069,000436,000467,0007,000
84/7/2023140,000196,000403,00058,000153,000300,00069,00070,000241,000227,000280,000
94/8/202349,000488,000419,00079,0003,000141,000433,00079,000433,000192,000450,000
104/9/2023357,000242,000181,000303,000245,000148,000287,000414,00086,000424,000131,000
114/26/202388,0002,000414,00071,00098,00037,000377,000281,000141,000213,000332,000
124/27/202361,000245,00022,000349,000199,00045,00056,00019,000463,000266,000149,000
134/28/2023295,000161,000353,000411,000250,00031,000352,000248,000481,000235,000110,000
144/29/202349,000272,000279,000499,000150,00019,000158,000131,00029,000417,00077,000
154/30/2023500,000252,000180,000155,000300,000216,000467,00024,000457,000373,000414,000
16
17
18DateClosest DateABC
193/31/20233/31/2023476,000348,000455,000
204/30/20234/30/2023500,000252,000180,000
213/15/20233/1/2023267,00094,000220,000
223/16/20233/29/2023264,000330,00036,000
Sheet25
Cell Formulas
RangeFormula
B19:B22B19=INDEX($A$2:$A$15,MATCH(MIN(ABS($A$2:$A$15-A19)),ABS($A$2:$A$15-A19),0))
C19:E22C19=INDEX($B$2:$L$15,MATCH($B19,$A$2:$A$15,0),MATCH(C$18,$B$1:$L$1,0))
 
Upvote 0
I think this aught to work with an older version of excel if that is what you have.

MrExcelPlayground17.xlsx
ABCDEFGHIJKL
1DateABCDEFGHIJK
23/1/2023267,00094,000220,000266,000275,00043,000400,00084,00069,000448,000446,000
33/29/2023264,000330,00036,000178,000363,000221,000165,000475,000457,000113,000391,000
43/30/2023359,000220,000368,000247,0002,000343,000388,000198,000379,00077,00090,000
53/31/2023476,000348,000455,000488,00059,00023,00082,000462,000316,000406,000422,000
64/1/2023275,00071,000388,000475,000266,000366,000214,000339,000113,00097,000411,000
74/6/2023171,000193,000290,00032,000335,000262,00031,00069,000436,000467,0007,000
84/7/2023140,000196,000403,00058,000153,000300,00069,00070,000241,000227,000280,000
94/8/202349,000488,000419,00079,0003,000141,000433,00079,000433,000192,000450,000
104/9/2023357,000242,000181,000303,000245,000148,000287,000414,00086,000424,000131,000
114/26/202388,0002,000414,00071,00098,00037,000377,000281,000141,000213,000332,000
124/27/202361,000245,00022,000349,000199,00045,00056,00019,000463,000266,000149,000
134/28/2023295,000161,000353,000411,000250,00031,000352,000248,000481,000235,000110,000
144/29/202349,000272,000279,000499,000150,00019,000158,000131,00029,000417,00077,000
154/30/2023500,000252,000180,000155,000300,000216,000467,00024,000457,000373,000414,000
16
17
18DateClosest DateABC
193/31/20233/31/2023476,000348,000455,000
204/30/20234/30/2023500,000252,000180,000
213/15/20233/1/2023267,00094,000220,000
223/16/20233/29/2023264,000330,00036,000
Sheet25
Cell Formulas
RangeFormula
B19:B22B19=INDEX($A$2:$A$15,MATCH(MIN(ABS($A$2:$A$15-A19)),ABS($A$2:$A$15-A19),0))
C19:E22C19=INDEX($B$2:$L$15,MATCH($B19,$A$2:$A$15,0),MATCH(C$18,$B$1:$L$1,0))
Thanks for supplying the detailed reply, this works but not if there is no data in a date, for example model C has nothing in 3/31/2023, but they do for 3/30/2023, we would want to pull the closest date prior to 3/31, so the result should be 87,800. It varies by each of the models.
 
Upvote 0
Your expected results still do not match the data.
Maybe
Excel Formula:
=LET(f,CHOOSECOLS(FILTER(B2:K15,A2:A15<=A18),MATCH(B17,B1:K1,0)),FILTER(f,f<>"","no data"))
 
Upvote 0
Your expected results still do not match the data.
Maybe
Excel Formula:
=LET(f,CHOOSECOLS(FILTER(B2:K15,A2:A15<=A18),MATCH(B17,B1:K1,0)),FILTER(f,f<>"","no data"))
 

Attachments

  • Capture1.PNG
    Capture1.PNG
    35.1 KB · Views: 22
Upvote 0
Your expected results still do not match the data.
Maybe
Excel Formula:
=LET(f,CHOOSECOLS(FILTER(B2:K15,A2:A15<=A18),MATCH(B17,B1:K1,0)),FILTER(f,f<>"","no data"))
Adjusted expected results adjusted are shown above.

Thank you for this suggestion.

FYI: I entered in this formula and it retuned #SPILL!
 
Upvote 0
Your expected results still do not match the data.
Maybe
Excel Formula:
=LET(f,CHOOSECOLS(FILTER(B2:K15,A2:A15<=A18),MATCH(B17,B1:K1,0)),FILTER(f,f<>"","no data"))
Here are the results vs expected results. Am I missing something?
 

Attachments

  • Capture2.PNG
    Capture2.PNG
    52.2 KB · Views: 15
Upvote 0
Oops, forgot a bit, try
Excel Formula:
=LET(f,CHOOSECOLS(FILTER($B$2:$K$15,$A$2:$A$15<=$A18),MATCH(B$17,$B$1:$K$1,0)),TAKE(FILTER(f,f<>"","no data"),-1))
 
Upvote 0
Solution

Forum statistics

Threads
1,224,828
Messages
6,181,201
Members
453,022
Latest member
RobertV1609

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