title: Apply SUM formula to a range of cells showing the total every nth cell
body: <p>I have data as follows in my sheet:</p>
  <pre><code>DATE        DAY KM      SPD         MON/TOT TOTAL DIST.
                      
  2022.08.21  SUN 8.47 km 8.00 km/h   AUG--5  42.79 km
  2022.08.22  MON 8.62 km 7.90 km/h       
  2022.08.23  TUE 8.50 km 7.79 km/h       
  2022.08.25  THU 8.61 km 8.05 km/h       
  2022.08.28  SUN 8.59 km 8.39 km/h       
  2022.09.01  THU 9.10 km 8.25 km/h   SEP--2  10.10 km
  2022.09.01  THU 1.00 km 9.90 km/h       
  2022.10.01  SAT 9.60 km 8.00 km/h   OCT--4  26.30 km
  2022.10.01  SAT 2.00 km 8.00 km/h       
  2022.10.05  WED 5.00 km 8.70 km/h       
  2022.10.05  WED 9.70 km 6.00 km/h       
  2022.11.01  TUE 9.90 km 8.00 km/h   NOV--1  9.90 km
                  
  </code></pre>
  <p>I cannot figure out how to apply the formula (formula in Total Dist.) to the whole range as SUM does not work in ARRAYFORMULA, I have tried MMULT and SUMPRODUCT but was not successful.</p>
  <p>It might be a bit tough to understand so please take a look at the sheet.</p>
  <p><a href="https://docs.google.com/spreadsheets/d/1AuJ6BnVkgYRxwxstAz-iHKVX5XUbIaS-cQjr2xDLJr8/edit?usp=sharing" rel="nofollow noreferrer">https://docs.google.com/spreadsheets/d/1AuJ6BnVkgYRxwxstAz-iHKVX5XUbIaS-cQjr2xDLJr8/edit?usp=sharing</a></p>
  <p>Basically I never know how many times the activity will be done each month so I need a way to SUM the Total Distance and Total Speed through an ARRAYFORMULA so that the sheet does not get broken if extra rows are inserted. In the example above I entered the following formula in each cell manually but that is not feasible, the two formulas used in the &quot;Mon/Tot&quot; and &quot;Total Dist.&quot; are</p>
  <pre><code>=ARRAYFORMULA(IF(B4:B=&quot;&quot;,,(IF(I4:I=J4:J,,UPPER(TEXT(B4:B,&quot;MMM&quot;))&amp;IF(I4:I=J4:J,,&quot;--&quot;)&amp;IF(I4:I=J4:J,,COUNTIFS(B4:B,&quot;&gt;=&quot;&amp;B4:B, B4:B,&quot;&lt;=&quot;&amp;EOMONTH(B4:B,0))
  ))))) 
  </code></pre>
  <p>The above formula uses helper columns and tells you the Month (makes it easier to read the totals for the sheet users) and gives a count of how many times the activity has been done for the said month</p>
  <pre><code>=SUM(INDIRECT(&quot;D&quot;&amp;ROW()&amp;&quot;:D&quot;&amp;ROW()+INDEX(SPLIT(INDIRECT(&quot;F&quot;&amp;ROW()),&quot;--&quot;),1,2)-1))  
  </code></pre>
  <p>The above formula sums the Total Distance in the said month, dynamically as the sum range always changes depending on how many times the activity has been done in a said month --&gt; this is the formula I am trying to apply to the whole column through the use of an ARRAYFORMULA or the equivalent but have so far not been successful.</p>
  <p>Also, any advice on any of the other formulas is welcome as I am not sure as to them being the best way to achieve what they are achieving.</p>