Index with match and (maybe) offset?

Excellling

Board Regular
Joined
Sep 4, 2013
Messages
97
Office Version
  1. 365
Platform
  1. Windows
Hi All,

I have been digging around trying to find previous answers for my question but haven't been too successful.

I am trying to do a fairly simple index match but I think I need an offset thrown in there also.

For the example data below, I would like to feed in Fruit and Orange and 2026 and have it return 97.

I seem ok with the first two but not sure how to use the row with year in my formula to return the correct column but also index/match the first two columns.

1731905063027.png


Any suggestions and to improve my understanding of formulas would be appreciated.

Thanks
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Which version of Excel are you using? Please update your profile.
 
Upvote 0
Do you need to feed in both? Do you have any "Product" that would fit into more than one "Type" in column A?


Can you explain how you get 97 out of Fruit, Orange and 2026 from your sample data?
Sorry my random numbers must have updated on cell refresh. In the case above I am looking for 50, not 97.

In terms of product and type, yes I will have Products that will fit within multiple Types.
 
Upvote 0
Note: I've created a fictitious data set below thus won't match your image.

One way with INDEX/MATCH is to join Type and Product together as a string to find the row index (see B14).
I've also provided an alternative using dynamic functionality and formula in version 365 (see B16). Option 2 will return all instances.
Book1
ABCDEF
1Type Product2024202520262027
2FruitApple85428733
3FruitPear76407415
4FruitOrange85228388
5VegetablesAvocado38459880
6VegetablesZucc7055431
7VegetablesPotato28471554
8VegetablesSquash82812475
9VegetablesCarrot774310064
10FruitOrange77436564
11
12
13FruitOrange2026
14Option 183
15
16Option 283
1765
Sheet6
Cell Formulas
RangeFormula
B14B14=INDEX(C2:F10,XMATCH(A13&"|"&B13,A2:A10&"|"&B2:B10),XMATCH(C13,C1:F1))
B16:B17B16=TOCOL(IFS((A2:A10=A13)*(B2:B10=B13)*(C1:F1=C13),C2:F10),2)
Dynamic array formulas.
 
Upvote 0
Note: I've created a fictitious data set below thus won't match your image.

One way with INDEX/MATCH is to join Type and Product together as a string to find the row index (see B14).
I've also provided an alternative using dynamic functionality and formula in version 365 (see B16). Option 2 will return all instances.
Book1
ABCDEF
1Type Product2024202520262027
2FruitApple85428733
3FruitPear76407415
4FruitOrange85228388
5VegetablesAvocado38459880
6VegetablesZucc7055431
7VegetablesPotato28471554
8VegetablesSquash82812475
9VegetablesCarrot774310064
10FruitOrange77436564
11
12
13FruitOrange2026
14Option 183
15
16Option 283
1765
Sheet6
Cell Formulas
RangeFormula
B14B14=INDEX(C2:F10,XMATCH(A13&"|"&B13,A2:A10&"|"&B2:B10),XMATCH(C13,C1:F1))
B16:B17B16=TOCOL(IFS((A2:A10=A13)*(B2:B10=B13)*(C1:F1=C13),C2:F10),2)
Dynamic array formulas.
Thank you Cubist for the above.

The second option seems to work well, though it does seem to have an issue as it works for once cell but when I drag it I get a message saying 'Excel ran out of resources while attempting to calculate one or more formulas'. Not sure whether the formula is resource intensive?

This workbook hasn't had that error before.
 
Upvote 0
The second option seems to work well, though it does seem to have an issue as it works for once cell but when I drag it I get a message saying 'Excel ran out of resources while attempting to calculate one or more formulas'. Not sure whether the formula is resource intensive?
How large of a dataset are you working with?

Is it throwing the error with the INDEX/MATCH?
 
Upvote 0
I am assuming that the combinations in columns A & B will not repeat
24 11 18.xlsm
ABCDEF
1TypeProduct2024202520262027
2FruitApple85428733
3FruitPear76407415
4FruitOrange85228388
5VegetablesAvocado38459880
6VegetablesZucc7055431
7VegetablesPotato28471554
8VegetablesSquash82812475
9VegetablesCarrot774310064
10FruitPineapple77436564
11
12
13FruitOrange202683
14VegetablesPotato202428
15FruitApple202733
16VegetablesPineapple2024not found
17FruitApple2021not found
Excelling
Cell Formulas
RangeFormula
D13:D17D13=IFERROR(FILTER(FILTER(C$2:F$10,C$1:F$1=C13),(A$2:A$10=A13)*(B$2:B$10=B13)),"not found")
 
Upvote 0
I am assuming that the combinations in columns A & B will not repeat
24 11 18.xlsm
ABCDEF
1TypeProduct2024202520262027
2FruitApple85428733
3FruitPear76407415
4FruitOrange85228388
5VegetablesAvocado38459880
6VegetablesZucc7055431
7VegetablesPotato28471554
8VegetablesSquash82812475
9VegetablesCarrot774310064
10FruitPineapple77436564
11
12
13FruitOrange202683
14VegetablesPotato202428
15FruitApple202733
16VegetablesPineapple2024not found
17FruitApple2021not found
Excelling
Cell Formulas
RangeFormula
D13:D17D13=IFERROR(FILTER(FILTER(C$2:F$10,C$1:F$1=C13),(A$2:A$10=A13)*(B$2:B$10=B13)),"not found")
Thank you both, both options are working for me.

Cubist - option 1 with index/match
Peter - filter option also works, for me I haven't used filter in a formula before so good for my learning.

I appreciate your time and assistance
 
Upvote 0

Forum statistics

Threads
1,223,884
Messages
6,175,177
Members
452,615
Latest member
bogeys2birdies

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