Combining INDEX MATCH with multiple criteria, when one of the criterion is within a date range

mjmax

New Member
Joined
Aug 10, 2018
Messages
16
Office Version
  1. 365
Platform
  1. Windows
Hello, I've been using this formula to INDEX the Correct rate based on the Date Range the date falls.
=INDEX($B$7:$B$11,MIN(IF((J5>=$E$7:$E$11)*(J5<=$F$7:$F$11),MATCH(ROW($B$7:$B$11),ROW($B$7:$B$11)))))

This works well, but I have to manually write the formula for each Hotel and Room Type. But things get complicated when there are multiple options for hotels and room. I end up with really large IF statements combined with this basic index formula. I thought I could combine this INDEX formula with something like =INDEX(range1,MATCH(1,(A1=range2)*(B1=range3)*(C1=range4),0))} to first Match the "Rate Code" (D2:D21) (Textjoin of Hotel and Room) ((M5) then match the row to the date range. J5>=(E2:E21)*J5<=(F2:F21) to return the Rate (B2:B21)

Thanks in advance! Love this forum!

Example.xlsx
ABCDEFGHIJKLMN
1HotelRateRoomRateCodeStart DateEnd Date
2ABC1001ABC112/1/202212/23/2021
3ABC2001ABC112/24/20211/5/2022
4ABC1001ABC11/6/20223/31/2022DateHotelRoomRateCodeManual Rate
5ABC2001ABC14/1/20224/26/20224/3/2021ABC2ABC2300
6ABC1001ABC14/27/20226/23/20224/4/2021ABC2ABC2300
7ABC3002ABC212/1/202212/23/20214/5/2021ABC2ABC2300
8ABC4002ABC212/24/20211/5/20224/6/2021ABC2ABC2300
9ABC3002ABC21/6/20223/31/20224/7/2021BBC1BBC1600
10ABC4002ABC24/1/20224/26/20224/8/2021BBC1BBC1600
11ABC3002ABC24/27/20226/23/20224/9/2021BBC1BBC1600
12BBC6001BBC112/1/202212/23/20214/10/2021BBC1BBC1600
13BBC7001BBC112/24/20211/5/20224/11/2021BBC1BBC1600
14BBC6001BBC11/6/20223/31/2022
15BBC7001BBC14/1/20224/26/2022
16BBC6001BBC14/27/20226/23/2022
17BBC8002BBC212/1/202212/23/2021
18BBC9002BBC212/24/20211/5/2022
19BBC6002BBC21/6/20223/31/2022
20BBC7002BBC24/1/20224/26/2022
21BBC3002BBC24/27/20226/23/2022
22
Sheet1
Cell Formulas
RangeFormula
M5:M13M5=TEXTJOIN(,TRUE,K5,L5)
N5:N8N5=INDEX($B$7:$B$11,MIN(IF((J5>=$E$7:$E$11)*(J5<=$F$7:$F$11),MATCH(ROW($B$7:$B$11),ROW($B$7:$B$11)))))
N9:N13N9=INDEX($B$12:$B$16,MIN(IF((J9>=$E$12:$E$16)*(J9<=$F$12:$F$16),MATCH(ROW($B$12:$B$16),ROW($B$12:$B$16)))))
D2:D21D2=TEXTJOIN(,TRUE,A2,C2,)
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Where are you seeing an overlap? The dates represent 12/1/2021 - 6/23/2022 for each hotel and room 1/1/1900 - 11/30/2022 represents the dates before and 6/24/2022 - 1/1/3333 represents all dates after the date range. If you are seeing repeats, you may be referring to a different hotel and/or Room.

12/1/2021​
12/23/2021​
12/24/2021​
1/5/2022​
1/6/2022​
3/31/2022​
4/1/2022​
4/26/2022​
4/27/2022​
6/23/2022​
1/1/1900​
11/30/2022​
6/24/2022​
1/1/3333​
 
Upvote 0

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
On row 11 you have 6th Jan 22 to 31st Mar 22 & then on row 14 you have 1st Jan 1900 to 30th Nov 22.
Both of those ranges include 28th Feb 22, also both rows 21 & 22 include the date of 8th Jul 22
 
Upvote 0
Ok. I'm sorry. That is a typo. ? Thank you so much! ? This is much easier then I thought it would be. I'm sorry for my lack of attention to detail.

To anyone referring to this horrible example of my inability to full comprehend, but is looking for Fluff's solution to this problem here it is!

Excel Formula:
=FILTER($B$2:$B$200,($A$2:$A$200=K5)*($C$2:$C$200=L5)*($E$2:$E$200<=J5)*($F$2:$F$200>=J5))

Example.xlsx
ABCDEFGHIJKLMOPQ
1HotelRateRoomRateCodeStart DateEnd Date
2ABC1001ABC112/1/202112/23/2021
3ABC2001ABC112/24/20211/5/2022
4ABC1001ABC11/6/20223/31/2022DateHotelRoomRateCodeLooking for a easier formula to do thisThe correct Formula!
5ABC2001ABC14/1/20224/26/20222/28/2022ABC2ABC2300300
6ABC1001ABC14/27/20226/23/20226/2/2022BBC1BBC1600600
7ABCN/A1ABC11/1/190011/30/20214/6/2022ABC1ABC1200200
8ABCN/A1ABC16/24/20221/1/333312/16/2021ABC2ABC2300300
9ABC3002ABC212/1/202112/23/20216/5/2022BBC1BBC1600600
10ABC4002ABC212/24/20211/5/202212/26/2021ABC1ABC1200200
11ABC3002ABC21/6/20223/31/20222/6/2022ABC2ABC2300300
12ABC4002ABC24/1/20224/26/20226/18/2022BBC2BBC2300300
13ABC3002ABC24/27/20226/23/20221/1/2021BBC1BBC1N/AN/A
14ABCN/A2ABC21/1/190011/30/2021
15ABCN/A2ABC26/24/20221/1/3333
16BBC6001BBC112/1/202112/23/2021
17BBC7001BBC112/24/20211/5/2022
18BBC6001BBC11/6/20223/31/2022
19BBC7001BBC14/1/20224/26/2022
20BBC6001BBC14/27/20226/23/2022
21BBCN/A1BBC11/1/190011/30/2021
22BBCN/A1BBC16/24/20221/1/3333
23BBC8002BBC212/1/202112/23/2021
24BBC9002BBC212/24/20211/5/2022
25BBC6002BBC21/6/20223/31/2022
26BBC7002BBC24/1/20224/26/2022
27BBC3002BBC24/27/20226/23/2022
28BBCN/A2BBC21/1/190011/30/2021
29BBCN/A2BBC26/24/20221/1/3333
30
Sheet1
Cell Formulas
RangeFormula
M5M5=TEXTJOIN(,TRUE,K5,L5)
O5O5=IF(M5=$D$2,INDEX($B$2:$B$8,MIN(IF((J5>=$E$2:$E$8)*(J5<=$F$2:$F$8),MATCH(ROW($B$2:$B$8),ROW($B$2:$B$8))))),IF(M5=$D$9,INDEX($B$9:$B$15,MIN(IF((J5>=$E$9:$E$15)*(J5<=$F$9:$F$15),MATCH(ROW($B$9:$B$15),ROW($B$9:$B$15))))),IF(M5=$D$16,INDEX($B$16:$B$22,MIN(IF((J5>=$E$16:$E$22)*(J5<=$F$16:$F$22),MATCH(ROW($B$16:$B$22),ROW($B$16:$B$22))))),IF(M5=$D$23,INDEX($B$23:$B$29,MIN(IF((J5>=$E$23:$E$29)*(J5<=$F$23:$F$29),MATCH(ROW($B$23:$B$29),ROW($B$23:$B$29))))),"No Match"))))
P5:P8,P10:P13P5=FILTER($B$2:$B$200,($A$2:$A$200=K5)*($C$2:$C$200=L5)*($E$2:$E$200<=J5)*($F$2:$F$200>=J5))
M6:M13M6=TEXTJOIN(,TRUE,K6,L6)
O6:O13O6=IF(M6=$D$2,INDEX($B$2:$B$6,MIN(IF((J6>=$E$2:$E$6)*(J6<=$F$2:$F$6),MATCH(ROW($B$2:$B$6),ROW($B$2:$B$6))))),IF(M6=$D$9,INDEX($B$9:$B$13,MIN(IF((J6>=$E$9:$E$13)*(J6<=$F$9:$F$13),MATCH(ROW($B$9:$B$13),ROW($B$9:$B$13))))),IF(M6=$D$16,INDEX($B$16:$B$22,MIN(IF((J6>=$E$16:$E$22)*(J6<=$F$16:$F$22),MATCH(ROW($B$16:$B$22),ROW($B$16:$B$22))))),IF(M6=$D$23,INDEX($B$23:$B$29,MIN(IF((J6>=$E$23:$E$29)*(J6<=$F$23:$F$29),MATCH(ROW($B$23:$B$29),ROW($B$23:$B$29))))),"No Match"))))
P9P9=FILTER($B$2:$B$200,($A$2:$A$200=K9)*($C$2:$C$200=L9)*($E$2:$E$200<=J9)*($F$2:$F$200>=J9))
D2:D29D2=TEXTJOIN(,TRUE,A2,C2,)
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
Why have to array confirmed the formula ( ie with Ctrl Shift Enter) it should just be normally entered.
 
Upvote 0
Good point. I think just habit. Her is without the array.

Example.xlsx
ABCDEFGHIJKMN
1HotelRateRoomRateCodeStart DateEnd Date
2ABC1001ABC112/1/202112/23/2021
3ABC2001ABC112/24/20211/5/2022
4ABC1001ABC11/6/20223/31/2022DateHotelRoomRateCodeLooking for a easier formula to do thisThe correct Formula!
5ABC2001ABC14/1/20224/26/20222/28/2022ABC2ABC2300300
6ABC1001ABC14/27/20226/23/20226/2/2022BBC1BBC1600600
7ABCN/A1ABC11/1/190011/30/20214/6/2022ABC1ABC1200200
8ABCN/A1ABC16/24/20221/1/333312/16/2021ABC2ABC2300300
9ABC3002ABC212/1/202112/23/20216/5/2022BBC1BBC1600600
10ABC4002ABC212/24/20211/5/202212/26/2021ABC1ABC1200200
11ABC3002ABC21/6/20223/31/20222/6/2022ABC2ABC2300300
12ABC4002ABC24/1/20224/26/20226/18/2022BBC2BBC2300300
13ABC3002ABC24/27/20226/23/20221/1/2021BBC1BBC1N/AN/A
14ABCN/A2ABC21/1/190011/30/2021
15ABCN/A2ABC26/24/20221/1/3333
16BBC6001BBC112/1/202112/23/2021
17BBC7001BBC112/24/20211/5/2022
18BBC6001BBC11/6/20223/31/2022
19BBC7001BBC14/1/20224/26/2022
20BBC6001BBC14/27/20226/23/2022
21BBCN/A1BBC11/1/190011/30/2021
22BBCN/A1BBC16/24/20221/1/3333
23BBC8002BBC212/1/202112/23/2021
24BBC9002BBC212/24/20211/5/2022
25BBC6002BBC21/6/20223/31/2022
26BBC7002BBC24/1/20224/26/2022
27BBC3002BBC24/27/20226/23/2022
28BBCN/A2BBC21/1/190011/30/2021
29BBCN/A2BBC26/24/20221/1/3333
30
Sheet1
Cell Formulas
RangeFormula
K5K5=TEXTJOIN(,TRUE,I5,J5)
M5M5=IF(K5=$D$2,INDEX($B$2:$B$8,MIN(IF((H5>=$E$2:$E$8)*(H5<=$F$2:$F$8),MATCH(ROW($B$2:$B$8),ROW($B$2:$B$8))))),IF(K5=$D$9,INDEX($B$9:$B$15,MIN(IF((H5>=$E$9:$E$15)*(H5<=$F$9:$F$15),MATCH(ROW($B$9:$B$15),ROW($B$9:$B$15))))),IF(K5=$D$16,INDEX($B$16:$B$22,MIN(IF((H5>=$E$16:$E$22)*(H5<=$F$16:$F$22),MATCH(ROW($B$16:$B$22),ROW($B$16:$B$22))))),IF(K5=$D$23,INDEX($B$23:$B$29,MIN(IF((H5>=$E$23:$E$29)*(H5<=$F$23:$F$29),MATCH(ROW($B$23:$B$29),ROW($B$23:$B$29))))),"No Match"))))
N5:N13N5=FILTER($B$2:$B$200,($A$2:$A$200=I5)*($C$2:$C$200=J5)*($E$2:$E$200<=H5)*($F$2:$F$200>=H5))
K6:K13K6=TEXTJOIN(,TRUE,I6,J6)
M6:M13M6=IF(K6=$D$2,INDEX($B$2:$B$6,MIN(IF((H6>=$E$2:$E$6)*(H6<=$F$2:$F$6),MATCH(ROW($B$2:$B$6),ROW($B$2:$B$6))))),IF(K6=$D$9,INDEX($B$9:$B$13,MIN(IF((H6>=$E$9:$E$13)*(H6<=$F$9:$F$13),MATCH(ROW($B$9:$B$13),ROW($B$9:$B$13))))),IF(K6=$D$16,INDEX($B$16:$B$22,MIN(IF((H6>=$E$16:$E$22)*(H6<=$F$16:$F$22),MATCH(ROW($B$16:$B$22),ROW($B$16:$B$22))))),IF(K6=$D$23,INDEX($B$23:$B$29,MIN(IF((H6>=$E$23:$E$29)*(H6<=$F$23:$F$29),MATCH(ROW($B$23:$B$29),ROW($B$23:$B$29))))),"No Match"))))
D2:D29D2=TEXTJOIN(,TRUE,A2,C2,)
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
In future please mark the post that solved the the issue as the colution & not your post saying that it works. Thanks
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,219
Members
452,619
Latest member
Shiv1198

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