Find Unique Combination of 2 columns where both have re-occuring values

Hanumanji

New Member
Joined
Feb 17, 2022
Messages
9
Office Version
  1. 365
Platform
  1. Windows
Dear Excelisseurs,

I'm somewhat of an excel rookie so bear with me, I'm running flat with this one so I figured it's best to ask you.

Basically I want to return a value in column 2, but where the value in column 1 is equal to what I ask for.

For example in the table below, I want to be able to return "2" from table[Ingredients] where the value in table[Dish] is equal to "A" - which is easy with XLOOKUP. However I also want to be able to return "2" from table[Ingredients] where the value in table[Dish] is "B" or "C" or "D", you get my point. There might be 100s of dishes with the same ingredient, but I need to return the unique combination I ask for.

DishIngredientsQtyUnit
A15ml
A27ml
A34ml
A43ml
B11ml
B210ml
B315ml
B422ml


Thank you Kindly!
 
Sorry, forgot to update the comment under Dish-A table

Govindas - Recipe Book.xlsx
ABCDEFGHI
1DishIngredientsQtyUnitDish-A
2Dish-ABrown Sugar40mlBATCHES
3Dish-AButter40gIngredients4710
4Dish-AFlour100gBrown Sugar160ml
5Dish-AMilk0.5cupsButter
6Dish-BBrown Sugar50mlFlour
7Dish-BButter60gMilk
8Dish-BCream50mlCell G4 will use F4 and F1 to retrieve the value of QTY and multiply it by G3
9Dish-BFlour120g
10Dish-CCarrots10kg
11Dish-CCauliflower5kg
12Dish-DParsley4bunches
13Dish-DPotatoes20kg
Sheet2
Cell Formulas
RangeFormula
G4G4=C2*G3 & D2
 
Upvote 0

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Here's one way:

ABCDEFGHI
1DishIngredientsQtyUnitDish-A
2Dish-ABrown Sugar40mlBATCHES
3Dish-AButter40gIngredients4710
4Dish-AFlour100gBrown Sugar160 ml280 ml400 ml
5Dish-AMilk0.5cupsButter160 g280 g400 g
6Dish-BBrown Sugar50mlFlour400 g700 g1000 g
7Dish-BButter60gMilk2 cups3.5 cups5 cups
8Dish-BCream50ml
9Dish-BFlour120g
10Dish-CCarrots10kg
11Dish-CCauliflower5kg
12Dish-DParsley4bunches
13Dish-DPotatoes20kg
Sheet1
Cell Formulas
RangeFormula
F4:F7F4=FILTER(B2:B13,A2:A13=F1)
G4:I7G4=LET(f,FILTER(C2:D13,A2:A13=F1),INDEX(f,,1)*G3:I3& " "&INDEX(f,,2))
Dynamic array formulas.
 
Upvote 0
Here's one way:

ABCDEFGHI
1DishIngredientsQtyUnitDish-A
2Dish-ABrown Sugar40mlBATCHES
3Dish-AButter40gIngredients4710
4Dish-AFlour100gBrown Sugar160 ml280 ml400 ml
5Dish-AMilk0.5cupsButter160 g280 g400 g
6Dish-BBrown Sugar50mlFlour400 g700 g1000 g
7Dish-BButter60gMilk2 cups3.5 cups5 cups
8Dish-BCream50ml
9Dish-BFlour120g
10Dish-CCarrots10kg
11Dish-CCauliflower5kg
12Dish-DParsley4bunches
13Dish-DPotatoes20kg
Sheet1
Cell Formulas
RangeFormula
F4:F7F4=FILTER(B2:B13,A2:A13=F1)
G4:I7G4=LET(f,FILTER(C2:D13,A2:A13=F1),INDEX(f,,1)*G3:I3& " "&INDEX(f,,2))
Dynamic array formulas.

Thank you StephenCrump, although it is a neat solution my end use-case gets a tad bit more complex..
Parts of a dish may be prepared by multiple roles in the kitchen, therefore putting out an array in a predetermined range will not satisfy the required condition.
  • Goal: Ideally single-cell formula returning required value
This is another hardcoded example

ABCDEFGHI
1DishIngredientsQtyUnitKitchen Hand
2Dish-ABrown Sugar40mlIngredientsMonTueWed
3Dish-AButter40gCarrots37.5 kg37.5 kg37.5 kg
4Dish-AFlour100gPotatoes80 kg0 kg170 kg
5Dish-AMilk0.5cupsMilk5 cups6 cups5 cups
6Dish-BBrown Sugar50ml
7Dish-BButter60gCook Aide
8Dish-BCream50mlIngredientsMonTueWed
9Dish-BFlour120gCauliflower50 kg60 kg50 kg
10Dish-CCarrots2.5kgParsley4 bunches0 bunches8.5 bunches
11Dish-CCauliflower5kgButter400 g480 g400 g
12Dish-DParsley0.5bunches
13Dish-DPotatoes10kgBatches
14DishesMonTueWed
15Dish-A101210
16Dish-C151515
17Dish-D8017
Sheet2
Cell Formulas
RangeFormula
F3F3=B10
G3G3=G16*C10 & " " & D10
H3H3=H16*C10 & " " & D10
I3I3=I16*C10 & " " & D10
F4F4=B13
G4G4=G17*C13 & " " & D13
H4H4=H17*C13 & " " & D13
I4I4=I17*C13 & " " & D13
F5F5=B5
G5G5=G15*C5 & " " & D5
H5H5=H15*C5 & " " & D5
I5I5=I15*C5 & " " & D5
F9:F10F9=B11
G9G9=G15*C11 & " " & D11
H9H9=H15*C11 & " " & D11
I9I9=I15*C11 & " " & D11
G10G10=G17*C12 & " " & D12
H10H10=H17*C12 & " " & D12
I10I10=I17*C12 & " " & D12
F11F11=B3
G11G11=G15*C3 & " " & D3
H11H11=H15*C3 & " " & D3
I11I11=I15*C3 & " " & D3
 
Upvote 0
I thought about it, experimented a little and managed to develop a solution that achieves what I'm after by using XLOOKUP with FILTER.

I don't know if it's a pretty solution, feedback is welcome. I've just included a simple example, but it works as intended for the sheets I have.

Thank you everyone for the help so far, much appreciated!

ABCDEFGHIJ
1DishIngredientsQtyUnitBatches
2Dish-ABrown Sugar40ml51015
3Dish-AButter40gDish-BCream250 ml500 ml750 ml
4Dish-AFlour100g
5Dish-AMilk0.5cups
6Dish-BBrown Sugar50ml
7Dish-BButter60g
8Dish-BCream50ml
9Dish-BFlour120g
10Dish-CCarrots2.5kg
11Dish-CCauliflower5kg
12Dish-DParsley0.5bunches
13Dish-DPotatoes10kg
Sheet1
Cell Formulas
RangeFormula
H3H3=XLOOKUP(G3,FILTER(Table5[Ingredients],Table5[Dish]=F3),FILTER(Table5[Qty],Table5[Dish]=F3))*H2 & " " & XLOOKUP(G3,FILTER(Table5[Ingredients],Table5[Dish]=F3),FILTER(Table5[Unit],Table5[Dish]=F3))
I3I3=XLOOKUP(G3,FILTER(Table5[Ingredients],Table5[Dish]=F3),FILTER(Table5[Qty],Table5[Dish]=F3))*I2 & " " & XLOOKUP(G3,FILTER(Table5[Ingredients],Table5[Dish]=F3),FILTER(Table5[Unit],Table5[Dish]=F3))
J3J3=XLOOKUP(G3,FILTER(Table5[Ingredients],Table5[Dish]=F3),FILTER(Table5[Qty],Table5[Dish]=F3))*J2 & " " & XLOOKUP(G3,FILTER(Table5[Ingredients],Table5[Dish]=F3),FILTER(Table5[Unit],Table5[Dish]=F3))
 
Upvote 0
Solution
Would this be any use?


Hanumanji.xlsm
ABCDEFGHIJ
1DishIngredientsQtyUnitBatches
2Dish-ABrown Sugar40ml51015
3Dish-AButter40gDish-BCream250 ml500 ml750 ml
4Dish-AFlour100g
5Dish-AMilk0.5cups
6Dish-BBrown Sugar50ml
7Dish-BButter60g
8Dish-BCream50ml
9Dish-BFlour120g
10Dish-CCarrots2.5kg
11Dish-CCauliflower5kg
12Dish-DParsley0.5bunches
13Dish-DPotatoes10kg
14
Sheet1
Cell Formulas
RangeFormula
H3:J3H3=LET(f,FILTER(Table5,(Table5[[Dish]:[Dish]]=$F3)*(Table5[[Ingredients]:[Ingredients]]=$G3)),INDEX(f,3)*H2&" "&INDEX(f,4))
 
Upvote 0
Would this be any use?


Hanumanji.xlsm
ABCDEFGHIJ
1DishIngredientsQtyUnitBatches
2Dish-ABrown Sugar40ml51015
3Dish-AButter40gDish-BCream250 ml500 ml750 ml
4Dish-AFlour100g
5Dish-AMilk0.5cups
6Dish-BBrown Sugar50ml
7Dish-BButter60g
8Dish-BCream50ml
9Dish-BFlour120g
10Dish-CCarrots2.5kg
11Dish-CCauliflower5kg
12Dish-DParsley0.5bunches
13Dish-DPotatoes10kg
14
Sheet1
Cell Formulas
RangeFormula
H3:J3H3=LET(f,FILTER(Table5,(Table5[[Dish]:[Dish]]=$F3)*(Table5[[Ingredients]:[Ingredients]]=$G3)),INDEX(f,3)*H2&" "&INDEX(f,4))
Thank you, yeah that is a clean solution and it also helps me with a few other cases. Much appreciated!
 
Upvote 0

Forum statistics

Threads
1,215,866
Messages
6,127,403
Members
449,382
Latest member
DonnaRisso

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