Index Match - Multiple Criteria with a date range

Shayhoe

New Member
Joined
Mar 19, 2016
Messages
25
Hi All,

Hopefully the title is quite descriptive here, I'm essentially trying to do as I describe; I'm trying to do an Index Match with a few criteria, one of which is a date.

Here's an example below:

The formula will sit in an excel sheet which will be completed with the following information:

Brand - Brand A or Brand B
Product - Product A, Product B or Product C
Sale Date - Date in DD/MM/YYYY format

Using this information, I need to be able to return the document code that was valid during the specific product was sold. Every product for every brand has it's own document in roughly 1 month increments (Not always exactly a month, some run for a month and a bit or less than a month) there is only ever one document in place for each combination of brand/product/date at any one time.

My formula is it stands works but only if it's an exact date match - the formula is:


{=INDEX(M:M,MATCH(D3&E3&F3,J:J&K:K&L:L,0))}

Excuse the column references, these are aligned to my sheet but I don't have column headings on the data in thread(at the bottom of the question)

So in summary, is there a way to interrogate the below data with the data above and return a document code for the date range?

Hopefully this makes sense.

Thanks
[TABLE="width: 397"]
<tbody>[TR]
[TD]Brand[/TD]
[TD]Product[/TD]
[TD]Document used from[/TD]
[TD]Document Code[/TD]
[/TR]
[TR]
[TD]Brand A[/TD]
[TD]Product A[/TD]
[TD]01/01/1999[/TD]
[TD="align: right"]12345[/TD]
[/TR]
[TR]
[TD]Brand A[/TD]
[TD]Product B[/TD]
[TD]01/01/1999[/TD]
[TD="align: right"]12346[/TD]
[/TR]
[TR]
[TD]Brand A[/TD]
[TD]Product C[/TD]
[TD]01/01/1999[/TD]
[TD="align: right"]12347[/TD]
[/TR]
[TR]
[TD]Brand A[/TD]
[TD]Product A[/TD]
[TD]01/02/1999[/TD]
[TD="align: right"]12348[/TD]
[/TR]
[TR]
[TD]Brand A[/TD]
[TD]Product B[/TD]
[TD]01/02/1999[/TD]
[TD="align: right"]12349[/TD]
[/TR]
[TR]
[TD]Brand A[/TD]
[TD]Product C[/TD]
[TD]01/02/1999[/TD]
[TD="align: right"]12350[/TD]
[/TR]
[TR]
[TD]Brand A[/TD]
[TD]Product A[/TD]
[TD]01/03/1999[/TD]
[TD="align: right"]12351[/TD]
[/TR]
[TR]
[TD]Brand A[/TD]
[TD]Product B[/TD]
[TD]01/03/1999[/TD]
[TD="align: right"]12352[/TD]
[/TR]
[TR]
[TD]Brand A[/TD]
[TD]Product C[/TD]
[TD]01/03/1999[/TD]
[TD="align: right"]12353[/TD]
[/TR]
[TR]
[TD]Brand B[/TD]
[TD]Product A[/TD]
[TD]01/04/1999[/TD]
[TD="align: right"]12354[/TD]
[/TR]
[TR]
[TD]Brand B[/TD]
[TD]Product B[/TD]
[TD]01/04/1999[/TD]
[TD="align: right"]12355[/TD]
[/TR]
[TR]
[TD]Brand B[/TD]
[TD]Product C[/TD]
[TD]01/04/1999[/TD]
[TD="align: right"]12356[/TD]
[/TR]
[TR]
[TD]Brand B[/TD]
[TD]Product A[/TD]
[TD]01/05/1999[/TD]
[TD="align: right"]12357[/TD]
[/TR]
[TR]
[TD]Brand B[/TD]
[TD]Product B[/TD]
[TD]01/05/1999[/TD]
[TD="align: right"]12358[/TD]
[/TR]
[TR]
[TD]Brand B[/TD]
[TD]Product C[/TD]
[TD]01/05/1999[/TD]
[TD="align: right"]12359[/TD]
[/TR]
[TR]
[TD]Brand B[/TD]
[TD]Product A[/TD]
[TD]01/06/1999[/TD]
[TD="align: right"]12360[/TD]
[/TR]
[TR]
[TD]Brand B[/TD]
[TD]Product B[/TD]
[TD]01/06/1999[/TD]
[TD="align: right"]12361[/TD]
[/TR]
[TR]
[TD]Brand B[/TD]
[TD]Product C[/TD]
[TD]01/06/1999[/TD]
[TD="align: right"]12362[/TD]
[/TR]
</tbody><colgroup><col span="2"><col><col></colgroup>[/TABLE]
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
If the dates are guaranteed ascending for a Brand/Product combination then:


Book1
DEFGHIJKLM
1BrandProductDocument used fromDocument Code
2Brand AProduct A01/01/199912345
3Brand AProduct A15/02/199912348Brand AProduct B01/01/199912346
4Brand AProduct C01/01/199912347
5Brand AProduct A01/02/199912348
6Brand AProduct B01/02/199912349
7Brand AProduct C01/02/199912350
8Brand AProduct A01/03/199912351
9Brand AProduct B01/03/199912352
10Brand AProduct C01/03/199912353
11Brand BProduct A01/04/199912354
12Brand BProduct B01/04/199912355
13Brand BProduct C01/04/199912356
14Brand BProduct A01/05/199912357
15Brand BProduct B01/05/199912358
16Brand BProduct C01/05/199912359
17Brand BProduct A01/06/199912360
18Brand BProduct B01/06/199912361
19Brand BProduct C01/06/199912362
Sheet1
Cell Formulas
RangeFormula
G3{=INDEX($M:$M,MAX(IF($J:$J=$D$3,IF($K:$K=$E$3,IF($L:$L<$F$3,ROW($M:$M))))))}
Press CTRL+SHIFT+ENTER to enter array formulas.


WBD
 
Last edited:
Upvote 0
Hi,

Thanks for the quick reply. Can I just confirm my understanding that the formula you provided will only work if the data is sorted in ascending date order? Does the order of the other columns make any difference?

Thanks
 
Upvote 0
That's spot on, thanks for the help - one final thing (Columbo style) - is there a way to return a sort of Iferror with an array like this? so if a product/date/brand doesn't exist it returns a message or N/A etc?
 
Upvote 0
Sure. Just wrap an IFERROR() around it:

Code:
{=IFERROR(INDEX($M:$M,MAX(IF($J:$J=$D$3,IF($K:$K=$E$3,IF($L:$L<$F$3,ROW($M:$M)))))),"Not Found")}

WBD
 
Upvote 0

Forum statistics

Threads
1,224,824
Messages
6,181,186
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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