ciso
ciso

Reputation: 3050

Using Office365 Excel array formulas, how to calculate ytd totals for all rows and months?

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.

enter image description here

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

Answers (2)

Harun24hr
Harun24hr

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))))

enter image description here

Upvotes: 3

Harun24hr
Harun24hr

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)

enter image description here

Upvotes: 2

Related Questions