Reputation: 3050
Can one array formula calculate ytd totals for each month and name? See desired results. I tried doing it by row but getting a #calc! error.
Formula:
=LET(data,B5:D7,BYROW(data,LAMBDA(r,SCAN(0,r,LAMBDA(a,v,a+v)))))
Data:
Jan | Feb | Mar | |
---|---|---|---|
A | 1 | 2 | 3 |
B | 4 | 5 | 6 |
C | 7 | 8 | 9 |
Upvotes: 0
Views: 140
Reputation: 36880
Another cleaner approach could be using MAKEARRAY()
. Give a try to the following formula.
=MAKEARRAY(ROWS(B2:D4),COLUMNS(B2:D4),
LAMBDA(r,c,SUM(TAKE(CHOOSEROWS(B2:D4,r),1,c))))
Upvotes: 3
Reputation: 36880
You getting #CALC!
because BYROW()
can't return array output. It can only return single value. Try-
=DROP(REDUCE("",BYROW(B2:D4,LAMBDA(rw,TEXTJOIN("|",1,SCAN(0,rw,LAMBDA(a,x,a+x))))),LAMBDA(acc,dt,VSTACK(acc,TEXTSPLIT(dt,"|")))),1)
Upvotes: 2