I have a table of invoice which we have monthly amounts we expect to bill. We also have a factor on how long many months we expect to actually collect per invoice.
What I am attempting to do is take the monthly values array and reconstruct into into a new monthly table where the given invoice will be offset by the number of months delayed we expect to collect.
I have spill formulas that are calculating and determining how much wider the months need to go (ie: data ends in Dec 2026, but we expect our last collection to be in March 2026, therefore my formula will take the time period and extend 2 more periods).
The part I'm struggling with is how to write a Let/MakeArray formula that is able to shift the data over to the right by the number of months in the row. The closest formula I got would shift the data incorrectly to the left, I tried to use Hstack and sequence to fill in the x number of cells on the left with 0.
=LET(data,$C$5:$N$9,
height,SEQUENCE(COUNTA($B$20#)),
width,SEQUENCE(,COUNTA($C$19#)),
mfactor,$A$20#,
datarange, IFERROR(INDEX(data,height,width),0),
final,MAKEARRAY( ROWS(height), COLUMNS(width), LAMBDA(r,c, INDEX(DROP(datarange,,INDEX(mfactor,r)),r,c))),
IFERROR(final,0)
)
I've also tried, but this yielded a single cell 0 output:
=LET(data,$C$5:$N$9,
height,SEQUENCE(COUNTA($B$21#)),
width,SEQUENCE(,COUNTA($C$20#)),
mfactor,$A$21#,
datarange, IFERROR(INDEX(data,height,width),0),
final,MAKEARRAY( ROWS(height), COLUMNS(width), LAMBDA(r,c, HSTACK( TRANSPOSE(SEQUENCE(INDEX(mfactor,r),0,0,0)), INDEX(DROP(datarange,,INDEX(mfactor,r)),r,c) ))),
IFERROR(final,0)
)
In this image you will see the data source table at the top, the expected output in the middle, and what I tried and it's results at the bottom.
| Mfactor | Invoice | 1/1/2025 | 2/1/2025 | 3/1/2025 | 4/1/2025 | 5/1/2025 | 6/1/2025 | 7/1/2025 | 8/1/2025 | 9/1/2025 | 10/1/2025 | 11/1/2025 | 12/1/2025 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | 1 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 |
| 1 | 2 | 50 | 50 | 50 | 50 | 50 | 50 | 50 | 50 | 50 | 50 | 50 | 50 |
| 2 | 3 | 150 | 150 | 150 | 150 | 150 | 150 | 150 | 150 | 150 | 150 | 150 | 150 |
| 1 | 4 | 60 | 60 | 60 | 60 | 60 | 60 | 60 | 60 | 60 | 60 | 60 | 60 |
| 2 | 5 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 |


