"Inside out" multiple table lookup

phmalu

Board Regular
Joined
Jun 21, 2017
Messages
52
Office Version
  1. 2019
Platform
  1. Windows
If anyone is willing to help, I need a formula that is going to find "Product ID" (in row 2) considering user input product prices.
There are more instructions inside the sheet, right after the table. In F8:F10 I've put the results one'd expect to get using the formula.
Book1
ABCDEFGHIJKLM
1Product id
2id1id2id3id4id5id6id7id8id9id10
3Retail price7.5012.6024.409.209.2016.015.053.078.687.50
4Production cost5.0010.0020.006.008.0014.005.003.007.006.00
5
6
7Price typePriceProcuct id
8E.g 1Production cost8??<- expected resultid5
9E.g 2Retail price7.5??<- expected resultid1, id10
10E.g 3Retail price24.5??<- expected resultNo such product
11
12Price column (C8:C10) is user input
13Price type (B8:E10) is selected by user using drop-down
14Formula (D8:D10) must search for user price input (C8:C10) somewhere in B3:K4 then (if there is any) display matching id within row 2
15The tricky part is that If more than one result is valid (as shown in E.g 2 - G8), all results must be displayed one after the other [matching id A, matching id B… matching id N]
16Within my real data, most (but not all) "prices and costs" are unique inside their category. Hence, formula should only account for exact matches.
Sheet1
Cells with Data Validation
CellAllowCriteria
B8:B10List=$A$3:$A$4

p.s.: consider this table is generated by our internal system so unfortunately changing the way data is displayed should only be considered as a last resort.

Thank you!
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
eg1 does not match your sheet?
 
Upvote 0
Hey there, this should work, though a bit messy. Hope someone to come up with a more elegant solution.

Not sure how many columns are there in your spreadsheet, if more than OP, you may change the column width in two MATCH formulae and expand all references to COLUMN K.

Book1
ABCDEFGHIJK
1Product id
2id1id2id3id4id5id6id7id8id9id10
3Retail price7.512.624.49.29.216.015.053.078.687.5
4Production cost5102068145376
5
6
7Price typePriceProcuct id
8E.g 1Production cost8id5<- expected resultid5
9E.g 2Retail price7.5id1, id10<- expected resultid1, id10
10E.g 3Retail price24.5No such product<- expected resultNo such product
11
Sheet2
Cell Formulas
RangeFormula
D8:D10D8=IFERROR(LEFT(CONCAT(IF(OFFSET($A$2,MATCH($B8,$A$3:$A$4,0),0,1,11)=$C8,$A$2:$K$2&", ","")),LEN(CONCAT(IF(OFFSET($A$2,MATCH($B8,$A$3:$A$4,0),0,1,11)=$C8,$A$2:$K$2&", ","")))-2),"No such product")
 
Last edited:
Upvote 0
Another option
+Fluff 1.xlsm
ABCDEFGHIJK
1Product id
2id1id2id3id4id5id6id7id8id9id10
3Retail price7.512.624.49.29.216.015.053.078.687.5
4Production cost5102068145376
5
6
7Price typePriceProcuct id
8E.g 1Production cost8id5
9E.g 2Retail price7.5id1, id10
10E.g 3Retail price24.5No such product
11
Main
Cell Formulas
RangeFormula
D8:D10D8=IF(TEXTJOIN(", ",,IF(($A$3:$A$4=B8)*($B$3:$K$4=C8),$B$2:$K$2,""))="","No such product",TEXTJOIN(", ",,IF(($A$3:$A$4=B8)*($B$3:$K$4=C8),$B$2:$K$2,"")))
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
Solution
Hey there, this should work, though a bit messy. Hope someone to come up with a more elegant solution.

Not sure how many columns are there in your spreadsheet, if more than OP, you may change the column width in two MATCH formulae and expand all references to COLUMN K.

Book1
ABCDEFGHIJK
1Product id
2id1id2id3id4id5id6id7id8id9id10
3Retail price7.512.624.49.29.216.015.053.078.687.5
4Production cost5102068145376
5
6
7Price typePriceProcuct id
8E.g 1Production cost8id5<- expected resultid5
9E.g 2Retail price7.5id1, id10<- expected resultid1, id10
10E.g 3Retail price24.5No such product<- expected resultNo such product
11
Sheet2
Cell Formulas
RangeFormula
D8:D10D8=IFERROR(LEFT(CONCAT(IF(OFFSET($A$2,MATCH($B8,$A$3:$A$4,0),0,1,11)=$C8,$A$2:$K$2&", ","")),LEN(CONCAT(IF(OFFSET($A$2,MATCH($B8,$A$3:$A$4,0),0,1,11)=$C8,$A$2:$K$2&", ","")))-2),"No such product")
I might be a bit messy but it works, so thank you!
I surely appreciate your willingness to help me!
Another option
+Fluff 1.xlsm
ABCDEFGHIJK
1Product id
2id1id2id3id4id5id6id7id8id9id10
3Retail price7.512.624.49.29.216.015.053.078.687.5
4Production cost5102068145376
5
6
7Price typePriceProcuct id
8E.g 1Production cost8id5
9E.g 2Retail price7.5id1, id10
10E.g 3Retail price24.5No such product
11
Main
Cell Formulas
RangeFormula
D8:D10D8=IF(TEXTJOIN(", ",,IF(($A$3:$A$4=B8)*($B$3:$K$4=C8),$B$2:$K$2,""))="","No such product",TEXTJOIN(", ",,IF(($A$3:$A$4=B8)*($B$3:$K$4=C8),$B$2:$K$2,"")))
Press CTRL+SHIFT+ENTER to enter array formulas.
A great solution as always Fluff, thank you once again!
In this case it's a matter of curiosity more than anything else, but do you think it would be possible to tweak your formula slightly so no array is necessary in the same time that it uses no volatile functions (specially OFFSET and INDIRECT)? That's because I've had in the past optimization issues when using those in big sheets...
Thank you!
 
Upvote 0
I cannot think of a formula that would do that with your limitations.
 
Upvote 0

Forum statistics

Threads
1,214,638
Messages
6,120,676
Members
448,977
Latest member
moonlight6

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