I have the following:
col i: date (array formula)
col l: profit (array formula)
col k: aggregate profit (array formula)
col z: running max for col i (between 0 and running max), stop and restart when date change.
Like this:
Before Excel introduced array formulas I solved it with the following:
=MAX(0;MAXIFS($V$8:V8;$T$8:T8;I8))
with VBA code completing the entire column.
After Excel introduced array formulas I solved it with the following:
=MAP(i1#;k1#;LAMBDA(DATA;NET;MAX(0;MAXIFS($k$1:NET;$i$1:DATA;DATA))))
This spills the result for the entire column and the calculations are correct, however on 10,000 lines it is slow.
Is there a faster way, in Excel formula or VBA, to perform this operation?
I read a lot of answers for MAXIFS in this community but there are no answers for "spill" MAXIFS.
=LET(ddata,I8:I27,aData,K8:K27,
dc,ddata=VSTACK(INDEX(ddata,1)-1,DROP(ddata,-1)),
SCAN(0,SEQUENCE(ROWS(ddata)),LAMBDA(sr,r,LET(
a,INDEX(aData,r),
IF(INDEX(dc,r),IF(a>sr,a,sr),IF(a<0,0,a))))))