excelformulasumproduct

Sum of Monthly Instances That May Repeat For Several Additional Periods, but not Consistently


i have 8 years of monthly order volumes across columns, with each month having a variable period of service, starting in Jan-22. I would like to know the formula to calculate the number of active orders for any given month.

I've tried so many iterations using Sumproduct but I just can't figure it out!

I tried this: =SUMPRODUCT($A$2:C$2, --(COLUMN(C$1)-COLUMN($A$1)+1 <= $A$3:C$3))

I know what it needs to do: Determine the Start Month: For any given month, the potential start of the service could be as early as 100 months ago or as recent as the current month.

Determine if Orders in the Start Month are Still Active: For each potential start month, determine if the orders from that month are still active in the current month based on the service duration.

Sum the Active Orders: Sum all the orders from the months that are still active in the current month.

However, I cannot work out how to do it without using massive grids of cohort analysis (I have a lot of data).

For example:

In Row 1: Jan-22 | Feb-22 | Mar-22 | Apr-22

In Row 2 (Orders): 100 | 520 | 200 | 110

In Row 3 (Service Period in Months): 3 | 10 | 1 | 2

In Row 4 I'm looking for each month the number of active orders (the formula). The answers should be:

100 | 100 + 520 | 200 + 520 + 100 | 520 + 110

So you get something like this:

Jan-22 Feb-22 Mar-22 Apr-22
100 520 200 110
3 10 1 2
100 620 820 630

Solution

  • This is a little tricky and there's probably better ways to do this, but this seems to work.

    Using your example with below ranges, but this formula in cell B6 and drag to e6.

    =SUM(FILTER($B$3:B3,COLUMN($B$3:B3)+$B$4:B4>COLUMN()))

    enter image description here