XLOOKUP with multiple lookups vertical and horizontal

aquapowers

New Member
Joined
Jan 17, 2008
Messages
26
I'm trying to create the following lookup using XLOOKUP (or something else that works)

A1: K12 contains the data
Material in column A, quantity in B-F, prices in G-K.

The expected results are displayed in A16:A27.
The input field for each material is the quantity.
For example: Material 36580, input of 10 results in a price displayed in column C of 1267.75.
In this example, a quantity of 10 used the Q2 column quantity of 9, resulting in the P2 column of 1267.75.
The match mode for the quantity should be -1 (next smallest item in no exact match).



Book1.xlsx
ABCDEFGHIJK
1MaterialQ1Q2Q3Q4Q525p125p225p325p425p5
2365803918001444.291267.751123.320.000.00
33835810000634.100.000.000.000.00
47380910000324.700.000.000.000.00
5791233918001549.991360.541205.550.000.00
68341910000347.530.000.000.000.00
7880672048100248500237.61229.33218.29209.97204.44
88806832481002400297.57273.03245.02228.170.00
988128481002405001000164.29152.34141.83134.34127.66
1088129301002506000245.03229.69222.84213.240.00
118818925050000030.0427.340.000.000.00
1288195600100000013.4013.130.000.000.00
13
14
15
16MaterialQtyPrice
1736580101267.75
183835810634.10
197380910324.70
2079123191205.55
218341950347.53
2288067170209.97
23880685000228.17
2488128100152.34
2588129251213.24
26881892490.00
27881955000.00
Sheet1
Cell Formulas
RangeFormula
C17,C24C17=H2
C18:C19,C21C18=G3
C20C20=I5
C22:C23,C25C22=J7
C26:C27C26=XLOOKUP(B26,B11:F11,B11:F11,,-1)
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
How about:

Book1
ABC
16MaterialQtyPrice
1736580101267.75
183835810634.1
197380910324.7
2079123191205.55
218341950347.53
2288067170218.29
23880685000228.17
2488128100152.34
2588129251222.84
2688189249#N/A
2788195500#N/A
Sheet5
Cell Formulas
RangeFormula
C17:C27C17=INDEX($G$2:$K$12,MATCH(A17,$A$2:$A$12,0),MATCH(B17,IFERROR(1/(1/(INDEX($B$2:$F$12,MATCH(A17,$A$2:$A$12,0),0))),9999999)))


Depending on your version of Excel (2019 or older) you may need to enter the formula with Control+Shift+Enter.
 
Upvote 0
Solution
How about:

Book1
ABC
16MaterialQtyPrice
1736580101267.75
183835810634.1
197380910324.7
2079123191205.55
218341950347.53
2288067170218.29
23880685000228.17
2488128100152.34
2588129251222.84
2688189249#N/A
2788195500#N/A
Sheet5
Cell Formulas
RangeFormula
C17:C27C17=INDEX($G$2:$K$12,MATCH(A17,$A$2:$A$12,0),MATCH(B17,IFERROR(1/(1/(INDEX($B$2:$F$12,MATCH(A17,$A$2:$A$12,0),0))),9999999)))


Depending on your version of Excel (2019 or older) you may need to enter the formula with Control+Shift+Enter.
Thank you!! I get most of it, but can you explain how the IFERROR works. I'm stuck on that part.
 
Upvote 0
The IFERROR is sort of a trick in this case. Usually when you set up a range of values for a MATCH or LOOKUP function, especially if you're looking for the "exact number or next smallest item", the values must be in ascending sorted order. But you put 0 at the end of your ranges, e.g. 3,9,18,0,0. If you used 3,9,18,99999,99999 (where 99999 is some number bigger than any order you'll get), we wouldn't need the IFERROR. But in order to keep your original layout, I took the range of values that I found with the INDEX, say 3,9,18,0,0, and found the reciprocal (1/INDEX...), which turned that range into 1/3, 1/9, 1/18, #DIV/0, #DIV/0. Then I took the reciprocal again, giving 3,9,18,#DIV/0, #DIV/0. Finally the IFERROR kicks in, and converts the errors to 99999, giving 3,9,18,99999,99999, which is a range that MATCH can use.

Glad I could help! 😎
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,184
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