Forum Discussion

James_Buist's avatar
James_Buist
Copper Contributor
Nov 24, 2024
Solved

Dynamic Arrays - Changing a row by row Spilled Array to a block - Replacing Sumifs?

I have already had some help putting this together as a stop gap solution but need a more permanent one. File attached explains most. But I'm building a Depreciation Base which is how most Accountin...
  • djclements's avatar
    Nov 25, 2024

    Hi James, a couple of possibilities could be:

    =LET(
        data, F6:L8,
        yrs, D6:D8,
        one, INDEX(data, 1, 1),
        MAP(data, IF({1}, yrs, data), LAMBDA(v,n, SUM(TAKE(one:v, -1, -n))))
    )
    =LET(
        data, F6:L8,
        yrs, D6:D8,
        rwsλ, BYROW(data, LAMBDA(r, LAMBDA(r))),
        cols, SEQUENCE(, COLUMNS(data)),
        MAP(IF({1}, rwsλ, data), IF({1}, cols, data), IF({1}, yrs, data), LAMBDA(r,c,n, SUM(TAKE(TAKE(r(),, c),, -n))))
    )

    I'm not too sure which is more efficient, so I'll leave the speed testing to you. The attached file also includes a couple of SUMIFS options. Cheers!

Resources