[英]Using Google Sheets, how can I calculate the average per month based on multiple rows?
我有一個電子表格,我每次訪問商店時都會在每行輸入Groceries。 我已計算出總額,但現在我想計算雜貨的每月平均成本。
我甚至不知道從哪里開始。 我已發布電子表格( https://docs.google.com/spreadsheets/d/1R0zYMAigDULzm8oM2icsPK55BP162kVvctpx2cOSOIE/edit?usp=sharing )。
在B5中嘗試這個。 這將需要考慮年份和月份(因此1/17/2018將被視為從2017年1月7日起的單獨月份)。 它計算獨特的年 - 月組合並划分花費的總和。 減號計算空白單元計為唯一。
=sum(B9:B)/arrayformula(countunique(text(A9:A,"YYYY-MM"))-1)
相同的答案,使用雙重查詢:
=QUERY( QUERY({A8:B}, "select year(Col1), month(Col1), sum(Col2) group by year(Col1), month(Col1)"), "select avg(Col3) label avg(Col3) ''")
內部查詢是按年和月的總和報告:
式:
=QUERY({A8:B}, "select year(Col1), month(Col1), sum(Col2) group by year(Col1), month(Col1)")
結果:
year(Date) month(Date) sum Amount
2016 10 133.00
2017 0 80.00
2017 1 420.00
月份為零:0 - 1月2日 - 2月......
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.