Weekly Challenges

Solve the challenge, share your solution and summit the ranks of our Community!

Also available in | Français | Português | Español | 日本語
IDEAS WANTED

Want to get involved? We're always looking for ideas and content for Weekly Challenges.

SUBMIT YOUR IDEA

Challenge #65: Fulfilling Inventory Orders

JoeM
Alteryx Alumni (Retired)

Last week's challenge can be found HERE!

 

You have been given some order information that contains a list of orders with SKUs and related quantities. Additionally, you have a data set with the total inventory for each SKU.

You have been tasked with figuring out how to consume all of the inventory with the least amount of orders. In other words, you have been asked to fill the largest orders for each SKU in descending order.

 

Additionally, only complete orders may be fulfilled. For example, if an order calls for 4 units of a SKU, and only 3 are left in inventory, you can't fulfill the order.

SeanAdams
17 - Castor
17 - Castor

nice one!

 

this solution uses a basic "Fill in reverse size order" principle - but this doesn't guarantee maximum packing - with different order data, we may need to add an iterative macro or some other Knapsack process to maximize fill.

 

But for this input data, it matches the provided output.

 

Spoiler

65.png

BenMoss
ACE Emeritus
ACE Emeritus

Here's my solution :)

 

Loved that you made it sound so easy before the complete orders only caveat ;)

 

Spoiler
2017-04-10_15-21-38.png
NicoleJohnson
ACE Emeritus
ACE Emeritus

My solution.

Spoiler
WeeklyChallenge65.JPG
JoeM
Alteryx Alumni (Retired)

@BenMoss, I have to do at least one caveat. ;)

toddhowl
7 - Meteor

Had to do this one twice. The first time through I had way too many tools, so tried it again with fewer. :-)

 

Spoiler
Spoiler65.JPG
patrick_digan
17 - Castor
17 - Castor

I saw that many people have already provided similar looking solutions, so I decided to go down the iterative macro route that @SeanAdams mentioned. While I've created a macro that gets the correct answer and will allow for some more flexibility, it still has some major gaps. The iterative macro can be tweaked to find all combinations by unchecking the box (and then you could figure out the smallest set for sure), but it quickly blows up the processing because I haven't optimized it yet.   It's not very well laid out, but here is my basic logic:

Spoiler
You sort the orders from largest to smallest for a given SKU. You put a running total to get the sum as you keep adding up all the orders. You compare the running total to the needed quantity, and there are 3 basic things that can happen: 1) You find a 0 on some line which indicates that you've found a combination that fulfills the request. You want to spit this out of the iterative macro as a match. 2) You find that the running total at some point is greater than the needed quantity. In this case, you want to remove the offending number, and try again. 3)  You find that the running total never reaches the needed quantity. In this case, you want to "go backwards" and add back all numbers that are lower than the smallest number in your current set. It's the combination of 2 and 3 above in an iterative macro that would "eventually" find all the possible combinations so you could ensure that the smallest set was chosen. It would take way too many iterations the way it is currently setup to answer this for sure. Luckily the sample data matches the first match in my algorithm :)
MinaGO
7 - Meteor

My multirow is a bit crazy, I think it will be interesting to see what other people did. This was definitely a fun one! I never usually get to use multirow in such a way. Thanks Joe :)

Spoiler
Screenshot (311).png
Simona
7 - Meteor
Spoiler
Alteryx_65.PNG
I struggled a bit to be honest as I did not realize that the sorting was essential before the multirow, so I kept having more records and I was not sure why. Then I read more carefully the description of the challenge and I realised my mistake. Very good one!

It was a good exercise, these challenges are so neat and definitely I learnt a new technique once again! :)

Simona
7 - Meteor

Mina, I just downloaded your workflow and looked at your multirow formula. I did kind of similar thing but I used first a multirow to compute the cumulative/ running total, then a formula to calculate the difference. I like that you did the same just using the multirow formula!

 

Actually, you could also simplify a little bit your Multirow, as the last IF statement is not needed and you could substitute it with [Row-1:Remaining], so your calc would look like:

 

IF

(IF [Row-1:Order SKU]=[Order SKU] THEN [Row-1:Remaining] ELSE [Supply] ENDIF)-[Demand]>=0

THEN ((IF [Row-1:Order SKU]=[Order SKU] THEN [Row-1:Remaining] ELSE [Supply] ENDIF)-[Demand]) ELSE

[Row-1:Remaining]

ENDIF