Taking as many items from an ordered list as necessary to sum to a value

BenBl
New Member

Hey all,

I have a list of orders sorted by priority. Each order has a list of associated tasks sorted by step sequence. Each task has a duration.

e.g.

Order 1 priority 3:
Step 1) Unclamp 25 pieces. - 1 hour
Step 2) Mask 25 pieces. - 3 hours
step 3) Paint 25 pieces - 2 hours

Order 2 priority 2:
Step 1) Unclamp 13pieces. - .5 hour
Step 2) Mask 13 pieces. - 1.5 hours
step 3) Paint 13 pieces - 1 hours

Order 3 priority 1:
Step 1) Heat 60 pieces - 1.5 hours
Step 2) Package 60 pieces - 5 hours.

I want to pick all the tasks that sum to less than an amount of person-hours. For example, say I want to schedule 11 person hours for tomorrow.

Start at the highest priority, and add as many steps as possible to a total of less than 11 hours.

O3 S1 (1.5 hours), 03 S2 (5 hours), O2 S1 (0.5 hours), O2 S2 (1.5 hours), O2 S3 (1 hour), O1 S1 (1 hour) STOP. (We canโ€™t add O1 S2 without going above 11 hours).

How do you recommend doing this? Do I need to use a Steve-recursive actions hack or is there a formula that will do the trick?

0 1 171
1 REPLY 1

Oooo, thatโ€™s an interesting challenge! Iโ€™ll give it a quick shot here.

Hmmm, letโ€™s assume you are needing to assign a bunch of these to multiple people, yah? And possibly every day? So I think weโ€™ll need 2 columns in the tasks table, [person] and [date]. When both of these are filled out (at the same time), thatโ€™ll indicate that a task has been โ€œcoveredโ€ or โ€œassignedโ€.

Letโ€™s next make a slice for โ€œmy tasks todayโ€

AND( [person] = USEREMAIL() , [date] = TODAY() )

Letโ€™s also make a slice for โ€œmy available tasks to assignโ€

AND( 
  ISBLANK( [person] ) , 
  ISBLANK( [date] ) ,
  [task time] <= 11 - SUM( my tasks today[task time] )
 )

Then we can select the next task to assign with:

INDEX( ORDERBY( 
  my available tasks to assign[key-column] ,
  [priority]
  ) , 1 
)

Then, yes, weโ€™ll use โ€œrecursiveโ€ actions. Setup an Action that sets the [person] and [date] column. Then I think you just have to loop over that single action, with a looping condition of ISNOTBLANK( my available tasks to assign[key-column] ).

Good luck!

Top Labels in this Space