Arrayformula Running Total with multiple columns

一个人想着一个人 提交于 2021-02-10 20:18:29

问题


I've got the following task to solve, but I can't wrap my head around it.

There are a couple of numbers for different years. I would like to have a running total sum of all columns (= range C:I) in column J. I can do that with a formula in every cell of J - however I need to achieve it with a single arrayformula in J2.

What i figured after a lot of research are 2 steps:

  1. replace empty cells with 0s, since arrayformulas obviously have some problems with empty cells
  2. make a sum of each row

For step 1 the formula is: =ARRAYFORMULA(IF(ISBLANK(C2:I15),0,C2:I15)) which gives me back a temporary array like:

As this is a 15x7 array, I need something like a 7x1 array to multiply with in order to get a 15x1 array.

That formula would be: =ARRAYFORMULA(TRANSPOSE(COLUMN(C1:I1)^0))

So in the end my formula so far look like: =ARRAYFORMULA(MMULT(IF(ISBLANK(C2:I15),0,C2:I15),TRANSPOSE(COLUMN(C1:I1)^0)))

And this results in a 15x1 array that gives me the sum per row, but not a total running sum of all rows.

This is where I am stuck - any help and ideas are greatly appreciated.

EDIT: added a shared version for you to fiddle: https://docs.google.com/spreadsheets/d/1cqNEsWHqBaHdDrMY8x4DUKpEkYprRZ8AibEe7d0knPY/edit?usp=sharing


回答1:


try:

=ARRAYFORMULA(IF(B2:B="";;MMULT(TRANSPOSE((ROW(M2:M)<=TRANSPOSE(ROW(M2:M)))*
 MMULT(C2:I*1; ROW(A1:A7)^0)); SIGN(MMULT(C2:I*1; ROW(A1:A7)^0))^0)))




回答2:


I think this will work too:

=ARRAYFORMULA(IF(B2:B="";;SUMIF(SEQUENCE(ROWS(C2:I);COLUMNS(C2:I));"<="&SEQUENCE(ROWS(C2:I);1;COLUMNS(C2:I);COLUMNS(C2:I));C2:I)))


来源:https://stackoverflow.com/questions/59811986/arrayformula-running-total-with-multiple-columns

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!