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!
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Basically I want to return a value in column 2, but where the value in column 1 is equal to what I ak for.
How about: =IF(OR(table[dish]="A",table[dish]="B",table[dish]="C",table[dish]="D"),2,"")

I believe this fulfills what you have requested, but perhaps you have not been clear enough. There are hundreds of dishes and the number of Ingredients will vary for each. Somewhere else you wish to type, for example, dish "F" and the next cell you show "5" which would be the specific number of ingredients for it, is this it?
 
Upvote 0
How about: =IF(OR(table[dish]="A",table[dish]="B",table[dish]="C",table[dish]="D"),2,"")

I believe this fulfills what you have requested, but perhaps you have not been clear enough. There are hundreds of dishes and the number of Ingredients will vary for each. Somewhere else you wish to type, for example, dish "F" and the next cell you show "5" which would be the specific number of ingredients for it, is this it?
Thank you. Sorry, I'll clarify with this table - it was probably a mistake to put numbers as an example in ingredients

DishIngredientsQtyUnit
ABrown Sugar20ml
AFlour20ml
AMilk20ml
AButter20ml
BBrown Sugar20ml
BFlour20ml
BCream20ml
BButter20ml



Example: Find & Return Brown Sugar where dish = A, or Find & Return Brown Sugar where dish = B (or any dish in a list that might be updated with time)
 
Upvote 0
Could you lead me on to what the solution would look like in Ex365? I can accept a VBA solution, but I'd prioritise a solution without
I am not sure I can help with Ex365. Hope someone with Ex365 stop by and give help.
 
Upvote 0
Welcome to the Forum!

It's not at all clear from Posts #1 and #4 what results you are expecting.

But I am guessing:

ABCD
1DishIngredientsQtyUnit
2ABrown Sugar1ml
3AFlour2ml
4AMilk3ml
5AButter4ml
6BBrown Sugar5ml
7BFlour6ml
8BCream7ml
9BButter8ml
10
11
12Brown Sugar
13ABrown Sugar1ml
14BBrown Sugar5ml
Sheet1
Cell Formulas
RangeFormula
A13:D14A13=FILTER(A2:D9,B2:B9=A12)
Dynamic array formulas.

If that's not right, please provide some examples.
 
Upvote 0
Welcome to the Forum!

It's not at all clear from Posts #1 and #4 what results you are expecting.

But I am guessing:

ABCD
1DishIngredientsQtyUnit
2ABrown Sugar1ml
3AFlour2ml
4AMilk3ml
5AButter4ml
6BBrown Sugar5ml
7BFlour6ml
8BCream7ml
9BButter8ml
10
11
12Brown Sugar
13ABrown Sugar1ml
14BBrown Sugar5ml
Sheet1
Cell Formulas
RangeFormula
A13:D14A13=FILTER(A2:D9,B2:B9=A12)
Dynamic array formulas.

If that's not right, please provide some examples.

Thank you Sir!

I've experimented with the filter function, but not sure how to get the right dynamic out of it to use the resulting array in calculations.
See if this helps, this is the basic action I'd like to achieve.

DishIngredientsQtyUnitDish-A
Dish-ABrown Sugar40ml4710
Dish-AButter40gBrown Sugar
Dish-AFlour100gButter
Dish-AMilk0.5cupsFlour
Dish-BBrown Sugar50mlMilk
Dish-BButter60g
Dish-BCream50mlCell G3 will use F3 and F1 to retrieve the value of QTY and multiply it by G2
Dish-BFlour120g
 
Upvote 0
That's a bit different to what you've described so far ....

Can you please post again using XL2BB, choosing Generate Output rather than Table Only Output, so we can see your cell references, and showing what's in cells F1, F3 and G2.

What results are you expecting? Do you want to multiply the recipe quantities by 4, 7 and 10?
 
Upvote 0
That's a bit different to what you've described so far ....

Can you please post again using XL2BB, choosing Generate Output rather than Table Only Output, so we can see your cell references, and showing what's in cells F1, F3 and G2.

What results are you expecting? Do you want to multiply the recipe quantities by 4, 7 and 10?
Thank you,

For me the main issue is finding the unique combination of the ingredient and dish I'm looking for.
If I was able to retrieve a specific Ingredient and it's location (coordinates) in the table for a specific Dish, I would be able to solve the rest.

But maybe there is a better solution? Here's an example of what I'm after with a fixed formula to solve G4 in the updated table. I need it to be dynamic though as the table and it's content might change over time.

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 G3 will use F3 and F1 to retrieve the value of QTY and multiply it by G2
9Dish-BFlour120g
10Dish-CCarrots10kg
11Dish-CCauliflower5kg
12Dish-DParsley4bunches
13Dish-DPotatoes20kg
Sheet2
Cell Formulas
RangeFormula
G4G4=C2*G3 & D2
 
Upvote 0

Forum statistics

Threads
1,215,758
Messages
6,126,713
Members
449,332
Latest member
nokoloina

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