Possible for Excel?

Supurbub

New Member
Joined
Jul 6, 2024
Messages
6
Office Version
  1. 365
Platform
  1. Windows
Hello-

I am fairly strong on Excel formulas and have very lightly dabbled with Power Query/Pivot. My work has been making a manual schedule for quite a while and I am trying to get it automated. Our ERP does not have the capability so my best bet is to try to get this to work in Excel... unless there is another suggestion?
To oversimplify- we have giant sheets of material (Umbrellas) that we cut parts out of. These parts go to different companies. Some umbrellas may make 10 of the same part or may make 7 different parts or any combination of.
Our demand for parts fluctuates by month based on customer needs. The goal is to figure out the most efficient way (least # of umbrellas used) to satisfy customer demand.

The image below is contains some made up umbrella and part #s. We have over 75 parts and 20 different part numbers but I would imagine the solution would be the same conceptually.
1720296148348.png


My demand would look something like this:
1720296253624.png


The goal is to populate the ? with the minimum amount of umbrellas needed to satisfy the monthly quota. Leftovers can be used the next month (in other words, if you build 8 of 234-4 in May, you can use the last one to support the 1 demand in June)
I wouldn't be opposed to using PowerQuery, formulas, etc. but my work does disable Macros. My ability with them is very weak so I may need extra help if that is the best route (Sorry and thank you in advance!)

Thank you for any help that you can give!
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Cannot manipulate data in a picture. Please reload the samples using XL2BB so that we don't have to try and recreate your data.
 
Upvote 0
Hello-

I am fairly strong on Excel formulas and have very lightly dabbled with Power Query/Pivot. My work has been making a manual schedule for quite a while and I am trying to get it automated. Our ERP does not have the capability so my best bet is to try to get this to work in Excel... unless there is another suggestion?
To oversimplify- we have giant sheets of material (Umbrellas) that we cut parts out of. These parts go to different companies. Some umbrellas may make 10 of the same part or may make 7 different parts or any combination of.
Our demand for parts fluctuates by month based on customer needs. The goal is to figure out the most efficient way (least # of umbrellas used) to satisfy customer demand.

The image below is contains some made up umbrella and part #s. We have over 75 parts and 20 different part numbers but I would imagine the solution would be the same conceptually.
View attachment 113778

My demand would look something like this:
View attachment 113779

The goal is to populate the ? with the minimum amount of umbrellas needed to satisfy the monthly quota. Leftovers can be used the next month (in other words, if you build 8 of 234-4 in May, you can use the last one to support the 1 demand in June)
I wouldn't be opposed to using PowerQuery, formulas, etc. but my work does disable Macros. My ability with them is very weak so I may need extra help if that is the best route (Sorry and thank you in advance!)

Thank you for any help that you can give
Figured out how to get the xl2bb to work. The data is below:
Umbrella Demand.xlsx
ABCDEFGHIJKLMN
1UmbrellaCreates:Quantity# Required by MonthMayJuneJulyAugustSeptemberOctoberNovemberDecember
2ABC-1234-11234-15112736107
3234-23234-231635525
4234-41234-471469423
5ABC-2555-13555-190537341
6234-12446-326459742
7446-32777-834473657
8ABC-3555-17
9ABC-4234-45
10446-31Umbrella DemandMayJuneJulyAugustSeptemberOctoberNovemberDecember
11ABC-5777-89ABC-1?
12ABC-6777-81ABC-2?
13555-12ABC-3?
14234-21ABC-4?
15234-11ABC-5?
16446-31ABC-6?
Umbrella Part #s


Thank you for the reply and any future help.
 
Upvote 0
Load first table
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table3"]}[Content],
    #"Filled Down" = Table.FillDown(Source,{"Umbrella"}),
    #"Changed Type" = Table.TransformColumnTypes(#"Filled Down",{{"Umbrella", type text}, {"Creates:", type text}, {"Quantity", Int64.Type}})
in
    #"Changed Type"
Load Second Table
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table4"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"# Required by Month", type text}, {"May", Int64.Type}, {"June", Int64.Type}, {"July", Int64.Type}, {"August", Int64.Type}, {"September", Int64.Type}, {"October", Int64.Type}, {"November", Int64.Type}, {"December", Int64.Type}}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"# Required by Month"}, "Attribute", "Value")
in
    #"Unpivoted Other Columns"
Join the two tables.
Power Query:
let
    Source = Table.NestedJoin(Table3, {"Creates:"}, Table4, {"# Required by Month"}, "Table4", JoinKind.LeftOuter),
    #"Expanded Table4" = Table.ExpandTableColumn(Source, "Table4", {"Attribute", "Value"}, {"Attribute", "Value"}),
    #"Inserted Multiplication" = Table.AddColumn(#"Expanded Table4", "Multiplication", each [Quantity] * [Value], Int64.Type),
    #"Renamed Columns" = Table.RenameColumns(#"Inserted Multiplication",{{"Multiplication", "Requirements"}}),
    #"Removed Other Columns" = Table.SelectColumns(#"Renamed Columns",{"Umbrella", "Attribute", "Requirements"}),
    #"Pivoted Column" = Table.Pivot(#"Removed Other Columns", List.Distinct(#"Removed Other Columns"[Attribute]), "Attribute", "Requirements", List.Sum)
in
    #"Pivoted Column"

My results
Book2
FGHIJKLMN
18UmbrellaMayJuneJulyAugustSeptemberOctoberNovemberDecember
19ABC-12115242227251825
20ABC-24134273345354021
21ABC-363035214921287
22ABC-43711243554271417
23ABC-52736366327544563
24ABC-63122262834302923
Sheet2


Since you did not provide expected results, I hope my solution meets your needs.
 
Upvote 0
Load first table
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table3"]}[Content],
    #"Filled Down" = Table.FillDown(Source,{"Umbrella"}),
    #"Changed Type" = Table.TransformColumnTypes(#"Filled Down",{{"Umbrella", type text}, {"Creates:", type text}, {"Quantity", Int64.Type}})
in
    #"Changed Type"
Load Second Table
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table4"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"# Required by Month", type text}, {"May", Int64.Type}, {"June", Int64.Type}, {"July", Int64.Type}, {"August", Int64.Type}, {"September", Int64.Type}, {"October", Int64.Type}, {"November", Int64.Type}, {"December", Int64.Type}}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"# Required by Month"}, "Attribute", "Value")
in
    #"Unpivoted Other Columns"
Join the two tables.
Power Query:
let
    Source = Table.NestedJoin(Table3, {"Creates:"}, Table4, {"# Required by Month"}, "Table4", JoinKind.LeftOuter),
    #"Expanded Table4" = Table.ExpandTableColumn(Source, "Table4", {"Attribute", "Value"}, {"Attribute", "Value"}),
    #"Inserted Multiplication" = Table.AddColumn(#"Expanded Table4", "Multiplication", each [Quantity] * [Value], Int64.Type),
    #"Renamed Columns" = Table.RenameColumns(#"Inserted Multiplication",{{"Multiplication", "Requirements"}}),
    #"Removed Other Columns" = Table.SelectColumns(#"Renamed Columns",{"Umbrella", "Attribute", "Requirements"}),
    #"Pivoted Column" = Table.Pivot(#"Removed Other Columns", List.Distinct(#"Removed Other Columns"[Attribute]), "Attribute", "Requirements", List.Sum)
in
    #"Pivoted Column"

My results
Book2
FGHIJKLMN
18UmbrellaMayJuneJulyAugustSeptemberOctoberNovemberDecember
19ABC-12115242227251825
20ABC-24134273345354021
21ABC-363035214921287
22ABC-43711243554271417
23ABC-52736366327544563
24ABC-63122262834302923
Sheet2


Since you did not provide expected results, I hope my solution meets your needs.
Not quite but thank you for trying.
The numbers should be quite smaller. For example, if I built 21 of ABC-1, I would create
21 of 234-1
63 of 234-2
21 of 234-4

I only need
5 of 234-1
3 of 234-2
7 of 234-4
respectively for May.

Let's focus on just 234-1 for May only. I could build:
5 ABC-1
or 5 ABC-6
or 2 ABC-2 with 1 ABC-1 or ABC-5
That would satisfy the 234-1 quantity for May while also generating a surplus of other pieces. There is some combination of umbrellas that will satisfy the months demand most efficiently.

Another way to say it would be I will need 29 total pieces in May. To build this, there will be a number of umbrellas less than 29 to meet the demand since each umbrellas creates a minimum of 5 pieces.
 
Upvote 0
We have over 75 parts and 20 different part numbers but
When you wrote "75 parts", did you mean Umbrellas? Which can produce 20 different parts?
 
Upvote 0
How do you measures efficiency?
Parts needed/Parts produced? The higher the better.
Or min number of umbrellas cut? The lower the better.
 
Upvote 0
How do you measures efficiency?
Parts needed/Parts produced? The higher the better.
Or min number of umbrellas cut? The lower the better.
Hello. Minimum numbers of umbrellas cut is the most efficient. The material for the umbrellas is extremely expensive.
The quantity of parts does not matter so long as it meets the minimum required each month (including carryover from previous month).
 
Upvote 0
Hi. It's still a work in progress, but I want to share how it goes so far. Later it could be done more efficiently with VBA I think.

I rearranged the quantity per umbrella parts table from this:
UmbrellaCreates:Quantity
ABC-1234-11
ABC-1234-23
ABC-1234-41
ABC-2555-13
ABC-2234-12
ABC-2446-32
ABC-3555-17
ABC-4234-45
ABC-4446-31
ABC-5777-89
ABC-6777-81
ABC-6555-12
ABC-6234-21
ABC-6234-11
ABC-6446-31


To this:
234-1234-2234-4446-3555-1777-8
ABC-1131---
ABC-22--23-
ABC-3----7-
ABC-4--51--
ABC-5-----9
ABC-611-121


And tried different values to satisfy the needs of May manually:

Umbrella.xlsx
BCDEFGHIJK
1234-1234-2234-4446-3555-1777-8Qty of each umbrella
2ABC-1131----
3ABC-22--23-2
4ABC-3----7--
5ABC-4--51--2
6ABC-5-----9-
7ABC-611-1213
8Result73109123744total parts produced
9
10# required in May53792329Total parts needed
110.659091Ratio
Sheet1
Cell Formulas
RangeFormula
C1:H1C1=TRANSPOSE(SORT(UNIQUE(Table1[Creates:])))
B2:B7B2=UNIQUE(Table1[Umbrella])
C2:H7C2=IFERROR(FILTER(Table1[[Quantity]:[Quantity]],(Table1[[Umbrella]:[Umbrella]]=$B2)*(Table1[[Creates:]:[Creates:]]=C$1)),0)
C8:H8C8=SUM(C2:C7*$I$2:$I$7)
I8I8=SUM(I2:I7)
J8,J10J8=SUM(C8:H8)
J11J11=J10/J8
Dynamic array formulas.
Cells with Conditional Formatting
CellConditionCell FormatStop If True
C8:H8Expression=C8>=C10textNO


Now I explain the process used in the later formula to automate the selection of umbrellas. Bear with me, it hopefully will make sense in the end.

I take the UmbrellaData and sort it randomly adding a random number column.

0.097034ABC-2200230
0.296713ABC-6110121
0.447708ABC-1131000
0.681586ABC-5000009
0.941866ABC-4005100
0.979925ABC-3000070


And then i take the needed part list of May (row AI1:AN1), and with the first row of UmbrellaData (Z2:AE2) and calculate how many umbrellas do I need to satisfy the needed parts (for the parts that the given umbrella has) with the formula in AG2.
Then with this max needed umbrella number I generate a random number between 0 and this max number.
After that i take that random number multiply it by the first row of UmbrellaData and substract it from the needed parts row (AI1:AN1) an place the result in AI2:AN2.
So i substract random number of umbrellas parts (in a random order) to the needed parts.


Umbrella.xlsx
XYZAAABACADAEAFAGAHAIAJAKALAMAN
1537923
20.097034ABC-220023054037103
30.296713ABC-611012133007000
40.447708ABC-113100071006000
50.681586ABC-500000900006000
60.941866ABC-400510021001000
70.979925ABC-300007000001000
Sheet1
Cell Formulas
RangeFormula
AI1:AN1AI1=C10:H10
X2:AE7X2=LET(d, $B$2:$H$7, req, $C$10:$H$10, rsd, SORT(HSTACK(RANDARRAY(ROWS(d)), d), 1), rsd )
AG2:AG7AG2=MAX(IFERROR(ROUNDUP(AI1#/Z2:AE2,0),0))
AH2:AH7AH2=RANDBETWEEN(0,AG2)
AI2:AN7AI2=LET(n, AI1#-Z2:AE2*AH2, IF(n<0, 0,n))
Dynamic array formulas.


For this to be a usefull result the last row has to be all 0. So that all the monthly needs are satisfied by the umbrellas used.
Then i take the amount of umbrellas used list (AH2:AH7) and with the umbrella list (Y2:Y7) I sort it back to the original order and place it it columns U and V.

Umbrella.xlsx
UVWXYZAAABACADAEAFAGAHAIAJAKALAMAN
1Sorted537923
2ABC-170.047535ABC-500000910537923
3ABC-200.185815ABC-300007011537903
4ABC-310.30289ABC-113100077000903
5ABC-420.678895ABC-611012197000200
6ABC-500.867311ABC-220023010000200
7ABC-670.922718ABC-400510022000000
817
9
100
Sheet1
Cell Formulas
RangeFormula
AI1:AN1AI1=C10:H10
U2:V7U2=SORT(HSTACK(Y2:Y7,AH2:AH7),1)
X2:AE7X2=LET(d, $B$2:$H$7, req, $C$10:$H$10, rsd, SORT(HSTACK(RANDARRAY(ROWS(d)), d), 1), rsd )
AG2:AG7AG2=MAX(IFERROR(ROUNDUP(AI1#/Z2:AE2,0),0))
AH2:AH7AH2=RANDBETWEEN(0,AG2)
AI2:AN7AI2=LET(n, AI1#-Z2:AE2*AH2, IF(n<0, 0,n))
V8V8=SUM(V2:V7)
V10V10=SUM(AI7#)
Dynamic array formulas.
Cells with Conditional Formatting
CellConditionCell FormatStop If True
V10Cell Value=0textNO


Every time I press F9 y get a new random result:

Sorted537923
ABC-110.020724ABC-500000910537923
ABC-200.087207ABC-113100071406923
ABC-300.445034ABC-611012191306802
ABC-460.501587ABC-400510086300202
ABC-500.573893ABC-220023020300202
ABC-610.903689ABC-300007000300202
8
7


Sorted537923
ABC-100.1047ABC-500000910537923
ABC-220.34529ABC-220023052137503
ABC-300.533193ABC-300007000137503
ABC-420.539549ABC-113100070137503
ABC-500.679267ABC-611012155007000
ABC-650.690539ABC-400510022000000
9
0


After many tries I got my best result so far for May, 7 umbrellas:

Umbrella.xlsx
BCDEFGHIJK
1234-1234-2234-4446-3555-1777-8Qty of each umbrella
2ABC-1131----
3ABC-22--23-2
4ABC-3----7--
5ABC-4--51--2
6ABC-5-----9-
7ABC-611-1213
8Result73109123744total parts produced
9
10# required in May53792329Total parts needed
110.659091Ratio
Sheet1
Cell Formulas
RangeFormula
C1:H1C1=TRANSPOSE(SORT(UNIQUE(Table1[Creates:])))
B2:B7B2=UNIQUE(Table1[Umbrella])
C2:H7C2=IFERROR(FILTER(Table1[[Quantity]:[Quantity]],(Table1[[Umbrella]:[Umbrella]]=$B2)*(Table1[[Creates:]:[Creates:]]=C$1)),0)
C8:H8C8=SUM(C2:C7*$I$2:$I$7)
I8I8=SUM(I2:I7)
J8,J10J8=SUM(C8:H8)
J11J11=J10/J8
Dynamic array formulas.
Cells with Conditional Formatting
CellConditionCell FormatStop If True
C8:H8Expression=C8>=C10textNO


Now I compacted the calculation in one cell and do 1000 of them in one go. And then i select the best result.
Almost every time I get the best result of 7 umbrellas.
Sometimes i get an spill error (don't know why, i had that before when you use a lot of dynamic array formulas. Out of memory or something) but it is only sometimes.

Basically what it does is try random umbrellas quantities and look if the random generated numbers satisfy the monthly needs, then select the best result (least umbrellas cut).
Maybe you wont get the absolute best result every time but i think it will be good enough. And you can process it many time until the numbers are as small as possible.

I hope all this makes some sense.

Here is the working file to download:
Umbrella 2.zip

For you to try it out and let me know what you think.
Could you maybe share the whole umbrella/parts quantity list? And some real data to try how it works with 20 umbrellas and 75 different parts?

If this works we could automate it further with VBA. So you just input the needed parts per month and click a button.
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,398
Latest member
rjsteward

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