Index:Match where the lookup matches a range perfectly, but the result is greater than or equal to...

RockandGrohl

Well-known Member
Joined
Aug 1, 2018
Messages
790
Office Version
  1. 365
Platform
  1. Windows
Sorry if that's confusing. There are two sheets, both have a unique reference on them. One is enquiry data, the other is booking data.

I need to match enquiry dates to booking dates to work out lead times, find out how long it takes our customers to book after requesting a brochure (enquiry)


A problem ensues when someone enquires on 5th May 2016, then books on 10th September 2016, then books another holiday again on the 4th July 17.

The formula I have that pulls through from the reference is showing the very latest booking, when in reality it needs to show the next booking after the enquiry date. Going back to this example, the lead time is being shown as 425 days when really it should be 128 days as their booking after the enquiry was approximately 4 months.

ENQUIRY DATA
CHJQRPResult
1Enquiry DateBook DateFirst EnquiryPrevious BookingLead TimeRef
205/05/2016Ignore05/05/201604/07/2017AAAA001Incorrect
3
405/05/2016Ignore05/05/201610/09/2016AAAA001Correct
5

<tbody>
</tbody>












What I need to see is their first booking AFTER the enquiry date.

On the example above, column Q is where the formula sits. Currently, it's this: =IFERROR(INDEX(BookData!H:H,MATCH(EnqData!P:P,BookData!N:N,0)),"")


BOOKING DATA
HJ__N
1Book DateTourRef
210/09/2016FranceAAAA001
301/03/2018YorkshireAAAA001
419/05/2018WeymouthAAAA001
512/10/2018GermanyBBLR056

<tbody>
</tbody>












Looking at the above, for customer AAAA001, the date I want to pull through in Column R is the next booking date greater than or equal to the enquiry date of 27/04/2018.

The correct answer would be 19/05/2018 which would have a lead time of approximately 20 or so days.

However, my current index-match will just pull through whatever's first on the list, which more often than not is incorrect.


So in summary, what I need is a formula to place in Q. This will index column H on 'bookdata', and match cell P2 on 'EnqData' against the range N:N on BookData... The tricky bit is only matching where the criteria that H in BookData is >= C2 in EnqData, but only the first largest one up, not the absolute largest in the range.


Do you think this is possible to do without an array formula? We have a list of 195,000 enquiries here
 
Last edited:

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Impossible without an array formula of some sort as its searching an array of values for your criteria. Can we assume that the data is in date order? Essentially that the next enquiry is placed at the bottom of the data? If so something like:

=IFERROR(INDEX(BookData!$H$2:$H$1000,MATCH(1,INDEX((BookData!$H$2:$H$1000>=C2)*(BookData!$N$2:$N$1000=P2),0),0)),"")

You will have to change the ranges to suit.
 
Upvote 0
Impossible without an array formula of some sort as its searching an array of values for your criteria. Can we assume that the data is in date order? Essentially that the next enquiry is placed at the bottom of the data? If so something like:

=IFERROR(INDEX(BookData!$H$2:$H$1000,MATCH(1,INDEX((BookData!$H$2:$H$1000>=C2)*(BookData!$N$2:$N$1000=P2),0),0)),"")

You will have to change the ranges to suit.

Thanks for this, I'll have to add a small change to my macro to re-sort the data when new data is applied, so it's always in date order.

Do the formulas have to be absolute? Currently they're set as H:H and N:N etc... is it possible to leave them as this or will it increase calculation time significantly?

Thanks.
 
Upvote 0
Also another thought, there are 190,000 rows with enquiry data, but the array formula probably only needs to go to around 10,000 rows.. Is there a way to prevent the array formula calculating a row it doesn't need to? Currently I have it set so that if the enquiry reference cannot be found in the booking data, then return blank, otherwise return the formula to give a booking date.

Is this correct or is there a faster way? Thanks.
 
Upvote 0
There's an option that I could write where the data didn't need sorting but it would be slow. If you could sort where most recent data was at the top and you knew all of your results would be captured by 1000 rows then it would be much faster but would need to be another formula. It's your data so you need to decide what is appropriate. You could even carve your data up so data not required could be archived away. Up to you really.
 
Upvote 0

Forum statistics

Threads
1,215,443
Messages
6,124,890
Members
449,194
Latest member
JayEggleton

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