Search code examples
google-sheetsarray-formulas

Calculate weekly sum in spreadsheet using array formula


I'm trying to calculate weekly sums in a single column, but I'm having trouble writing the formula. I'm found the the weeknum for every date in the year, but I can't find a way to sum up values if they have the same weeknum.

Link to my spreadsheet: https://docs.google.com/spreadsheets/d/1WIeBpRndO9ZBlkCcWQuNO1X4e9I6bGeQiYDTZqhaOeA/edit#gid=0

I'd like column "D" to automatically calculate the weekly sum using an array formula -- is there a way to do this?

This thread introduces the problem: Calculate weekly and monthly total in spreadsheet.


Solution

  • Chang sum() to sumif()

    =ARRAYFORMULA(IF(ROW(A:A)=1,"Weekly Sum", IF(WEEKDAY(A:A)=7, sumif(C:C,C:C,B:B),)))