Skip to main content

Hello community,

I'm looking for a cumulate grouped by Qty. I have a first metric which indicates my need of Qtés per week, and I need a second metric able to detect the week when I exceed the minimum to order. 
In my example, I have a minimum order of 6. 

In Line 1 I calculate my requirement per week. (that's done)
In Line 2 I want to trigger an order when I've reached at least my minimum order.

If I have that, it's already good 

In an ideal world, I'd have to reduce this quantity to the 1st week, a bit like a moving sum function but with variable parameters. 

If anyone has an algo idea, I'd be grateful ^^.

 

I finally passed part 1
Line 2 = 
if( previous( Week) >= 6 , 'Line 1', if( previous( Week) < 6 ,'Line 1' + PREVIOUS(Week),'Line 1'))



of course my 6 is variable in my prod


Hi Edgar,

Thanks for your question! We took a closer look and wanted to share a solution that meets your need: detecting when cumulative demand exceeds a minimum order quantity (MOQ), and triggering an order accordingly.

And here’s a possible solution:

We’re using the CUMULATE() function with a Batch# grouping:

  • requirement: weekly demand.

  • Cumulate Batch: CUMULATE(requirement, Month, Batch#) → resets per batch.

  • Batch#: Increases when MOQ is reached, creating dynamic groups.

  • Order new?: Boolean trigger when a batch reaches MOQ.

  • Stock Level: Simulates incoming orders and consumption.

This is what it would look like:
 

This setup avoids recursion, is easy to follow, and can be scaled to multiple products or dynamic MOQs.

Let us know if you have any questions.
Best regards,


Reply