Forum Discussion
sumif horiztonally and vertically
I have added a couple more solutions to Maciej_Kopczynski 's workbook. I program solely for 365 dynamic arrays so they look somewhat different. The main challenge is that your required layout is an array of arrays (month x division). That is a characteristic of most spreadsheet solutions but, regrettably, Microsoft decided that nested arrays should be treated as an error rather than the desired result.
My first solution uses array reshaping to lay the raw data out in a form that the basic summation by columns is a straightforward SUM rather than SUMIFS.
= LET(
reshaped, WRAPROWS(TOCOL(data), 24),
monthlyTotal, BYCOL(reshaped, LAMBDA(x, SUM(x))),
WRAPCOLS(monthlyTotal, 12)
)
The second approach uses SUMIFS, as suggested by the OP, but treats the divisions as two separate solutions which are then stacked to give the result. This would be very tedious if there were 100s of divisions or if the count of divisions needed to be dynamic.
= LET(
div1Totals, TOCOL(BYCOL(data, LAMBDA(d, SUMIFS(d, Division, "Division1")))),
div2Totals, TOCOL(BYCOL(data, LAMBDA(d, SUMIFS(d, Division, "Division2")))),
HSTACK(div1Totals, div2Totals)
)
Something that does work well is that the BYCOL helper function returns each column as a range reference rather than an array, so permitting the use of SUMIFS etc.
p.s. I appreciate that the OP ctone00 wanted to get results by 'dragging a formula down' but, since I haven't used that as a technique since 2015, I am definitely not the best person to address that requirement.