Calculate weekly and monthly total in spreadsheet

前端 未结 2 1671
无人及你
无人及你 2021-01-13 14:35

How to calculate weekly sum (sum of last 7 rows printed in 7th row) based on daily values, same question for monthly (based on weekly or daily). I have tried some formulas b

相关标签:
2条回答
  • 2021-01-13 14:44

    For weekly column

    =IF(IFERROR(WEEKNUM(A2)=WEEKNUM(A1), FALSE), "",SUM(B2:B8))
    

    for monthly column

    =IF(IFERROR(MONTH(A2)=MONTH(A1), FALSE), "",SUMIF(A2:A33, "<"&DATE(YEAR(A2),MONTH(A2)+1,1), B2:B33))
    

    these should work anywhere. Week & month sums will be listed on first day of week/month (what your sheet seemed to have)

    Note: the ranges in sumif are 31 days long. I realize every month isnt 31 days. But they are AT MOST 31 days, and each day will only be included if it's month is correct, so it holds for 28,29, and 30 day months as well. This means the formula WILL work for all months without modification.

    0 讨论(0)
  • 2021-01-13 15:03

    For the week column, you can add a formula like =IF(WEEKDAY(A8)=7,sum(B2:B8),"") (to put the sum of the week on Sundays.

    For the month column: =IF(MONTH(A2)<>MONTH(A2+1),SUM(B$2:B2)-SUMIF(A$2:A2,"<"&DATE(YEAR(A2),MONTH(A2),1),B$2:B2),"")

    0 讨论(0)
提交回复
热议问题