In Excel/Google Sheets I have found how to sum every N columns on websites such as
I need to do this with a formula and not a script.
CodePudding user response:
In M2:
=SUMPRODUCT(A2:J2,N(MOD(SEQUENCE(,COLUMNS(A2:J2),0),L2)=0))
and copied down.
CodePudding user response:
Google sheets formula:
=SUM(FILTER(A2:J2, MOD(COLUMN(A2:J2), L2)=0))
then drag to other cells
CodePudding user response:
Try this formula on column M:
=SUM((sumif(ArrayFormula(mod((COLUMN(B2:J2)-COLUMN(B2) 1),L2)),0,B2:J2)) A2)
Here's the result on Column M.
Just to break down the code sumif(ArrayFormula(mod((COLUMN(B2:J2)-COLUMN(B2) 1),L2)),0,B2:J2)
does the actual calculation with the number of intervals set on Column L but take note that I started at the 2nd column so the range here does not include the first column. The result from this is at the Column O highlighted red as you can see in the screenshot.
At the Column M is the actual solution where I only added the first column by using SUM on top of the previous formula.
I hope my explanation is clear.
Just copy/drag the formula down to each row and it should work.
Reference: How to Sum Every Nth Row or Column in Google Sheets Using SUMIF