Dynamic: Finding the Min and assigning to that category

Magoosball

Board Regular
Joined
Jun 4, 2017
Messages
70
Office Version
  1. 365
I have a spreadsheet with 2 separate sheets set up as follows:

Assignment:
[TABLE="width: 500"]
<tbody>[TR]
[TD]Department Bucket[/TD]
[TD]Shift
[/TD]
[TD]State[/TD]
[TD]Product[/TD]
[/TR]
[TR]
[TD]Home Health[/TD]
[TD]Nights[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Toys[/TD]
[TD]Nights[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Sporting Goods[/TD]
[TD]Nights[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Grocery[/TD]
[TD]Days[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Toys[/TD]
[TD]Days[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Furniture[/TD]
[TD]Days[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Pets[/TD]
[TD]Days[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

Summary:
[TABLE="width: 500"]
<tbody>[TR]
[TD]State[/TD]
[TD]Department Bucket[/TD]
[TD]Product[/TD]
[TD]Shift[/TD]
[TD]Number[/TD]
[/TR]
[TR]
[TD]Alabama[/TD]
[TD]Home Health[/TD]
[TD]Shampoo[/TD]
[TD]Nights[/TD]
[TD]1567[/TD]
[/TR]
[TR]
[TD]Alabama[/TD]
[TD]Toys[/TD]
[TD]Cars[/TD]
[TD]Nights[/TD]
[TD]900[/TD]
[/TR]
[TR]
[TD]Maryland[/TD]
[TD]Toys[/TD]
[TD]Barbies[/TD]
[TD]Nights[/TD]
[TD]897[/TD]
[/TR]
[TR]
[TD]Wyoming[/TD]
[TD]Home Health[/TD]
[TD]Conditioner[/TD]
[TD]Nights[/TD]
[TD]1570[/TD]
[/TR]
[TR]
[TD]Maryland[/TD]
[TD]Sporting Goods[/TD]
[TD]Basketball[/TD]
[TD]Nights[/TD]
[TD]65[/TD]
[/TR]
[TR]
[TD]Maryland[/TD]
[TD]Grocery[/TD]
[TD]Hot Dogs[/TD]
[TD]Days[/TD]
[TD]5[/TD]
[/TR]
[TR]
[TD]California[/TD]
[TD]Pets[/TD]
[TD]Dogs[/TD]
[TD]Days[/TD]
[TD]98[/TD]
[/TR]
[TR]
[TD]California[/TD]
[TD]Grocery[/TD]
[TD]Burgers[/TD]
[TD]Days[/TD]
[TD]74[/TD]
[/TR]
</tbody>[/TABLE]


The number column is a count statement from the assignment tab. For example from the above data there would be 1567 rows on the assignment tab that have a state of Alabama, a shift of nights, a department of Home Health and a Product of Shampoo. Since it is a count statement, for each additional row added to the assignment tab with Alabama, Home Health, Nights, and Shampoo, the number column on the summary spreadsheet would go up by 1.

The goal of this is to fill in the state and the product columns on the Assignment spreadsheet that has the lowest Number from the summary tab. Below I have typed out a few of the expected results.

1) Home Health Nights on the assignment tab -- The first 4 rows that have this on the assignment tab will be populated with Shampoo and Alabama. This would put the count of Alabama, Home Health, Shampoo, Nights at 1571 now. Since that is now greater than 1570 the next one will be assigned to Wyoming, Home Health, Conditioner, Nights. From here on out each row the formula is dragged down to that has these values should rotate between Alabama, Home Health, Shampoo, Nights AND Wyoming, Home Health, Conditioner, Nights.

2) Toys Nights on the assignment tab -- Each row on the assignment tab will be populated with Maryland and Barbie.

3) Grocery days on the assignment tab -- the first 69 should be assigned to Maryland Hot Dogs. The 70th row of this combination would be assigned to California burgers, and for each row after they would begin to rotate.

Is it possible to create this with formulas? Any helper columns are allowed. vb is allowed if needed.
I'm struggling because I'm getting a circular reference between the 2 tabs.

Any help setting this up or the formulas to make this happen would be greatly appreciated.
Thank you so much!
 
Last edited:

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Hi mate,

This seems to be returning the correct state & product for the lowest Summary value?


Book1
ABCD
1Department BucketShiftStateProduct
2Home HealthNightsAlabamaShampoo
3ToysNightsMarylandBarbies
4
5Sporting GoodsNightsMarylandBasketball
6GroceryDaysMarylandHot Dogs
7ToysDays
8FurnitureDays
9PetsDaysCaliforniaDogs
Assignment
Cell Formulas
RangeFormula
C2{=IFNA(INDEX(Summary!$A$2:$A$9,MATCH(MIN(IF(Summary!$B$2:$B$9&Summary!$D$2:$D$9=A2&B2,Summary!$E$2:$E$9)),Summary!$E$2:$E$9,0)),"")}
D2{=IFNA(INDEX(Summary!$C$2:$C$9,MATCH(MIN(IF(Summary!$B$2:$B$9&Summary!$D$2:$D$9=A2&B2,Summary!$E$2:$E$9)),Summary!$E$2:$E$9,0)),"")}
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
Solution

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

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