Fancy SQL Grouping

,

I have a need to group records in a BAQ where the sum of a number of rows will not exceed a certain value (in this case 17, but each upper group has it’s own Lot Size) unless the record itself is greater than the value. The below image is already filtered down to one group level for simplification. I need the Supply Qty to be summed and grouped. I already have a Running Total (partition by…) working, but as you can see I cant get the IDEAL value. I have included my previous attempts with ceiling, floor, and round, but I don’t think this is the correct approach.
image

I’m trying to understand what you need haha stand by

Yeah no… maybe try again? with play dough? (old phrase sorry)
I don’t understand what you need? please expand lol

Short version is I want to group by ProdLine, Kit, and Lot ID (which is an incremented value based off of a sum that must reset before the lot size is exceed.

Gory Details

Here is a fuller set of data. It is grouped by the Kit ID and The Prod Line. These define the Lot Size (simply the max size of the intended job). They are previously sorted by a date value (not shown) for each group. I want to provide a Lot ID that matches the “Desired” column. My first attempt was to get the running total for each group and divide that by the Lot Size to get a number that could be my Lot ID (using CEILING). However, it would often not create enough Lot IDs because a single Supply Qty could be more than the Lot Size (should be it’s own lot), but because the previous lots were small, it would not create a new subsequent lot.

1 Like

Could you get the base results and then use logic in the getlist to complete the data? I do this for our schedule where I have to break the hours out by the week.

Yes, but this limits how I can display the data.