简体   繁体   English

使用Google表格,如何根据多行计算每月平均值?

[英]Using Google Sheets, how can I calculate the average per month based on multiple rows?

I have a spreadsheet where I am entering Groceries on each row every time I visit a store. 我有一个电子表格,我每次访问商店时都会在每行输入Groceries。 I have calculated the overall sum, but now I would like to calculate the average cost per month for the groceries. 我已计算出总额,但现在我想计算杂货的每月平均成本。

在此输入图像描述

I don't even know where to begin on this. 我甚至不知道从哪里开始。 I have posted my spreadsheet ( https://docs.google.com/spreadsheets/d/1R0zYMAigDULzm8oM2icsPK55BP162kVvctpx2cOSOIE/edit?usp=sharing ). 我已发布电子表格( https://docs.google.com/spreadsheets/d/1R0zYMAigDULzm8oM2icsPK55BP162kVvctpx2cOSOIE/edit?usp=sharing )。

Try this in B5. 在B5中尝试这个。 It will take the year and month into account (so 1/7/2018 will count as a separate month from 1/7/2017). 这将需要考虑年份和月份(因此1/17/2018将被视为从2017年1月7日起的单独月份)。 It counts unique year-month combinations and divides the sum spent. 它计算独特的年 - 月组合并划分花费的总和。 The minus one accounts for the blank cell counted as unique. 减号计算空白单元计为唯一。

=sum(B9:B)/arrayformula(countunique(text(A9:A,"YYYY-MM"))-1)

same answer, using double query: 相同的答案,使用双重查询:

=QUERY( QUERY({A8:B}, "select year(Col1), month(Col1), sum(Col2) group by year(Col1), month(Col1)"), "select avg(Col3) label avg(Col3) ''")

The inside query is report with sums by years and months: 内部查询是按年和月的总和报告:

formula: 式:

=QUERY({A8:B}, "select year(Col1), month(Col1), sum(Col2) group by year(Col1), month(Col1)")

result: 结果:

year(Date)  month(Date) sum Amount

2016            10          133.00
2017            0            80.00
2017            1           420.00

Months are zero-based: 0 - Jan, 2 - Feb... 月份为零:0 - 1月2日 - 2月......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何根据条件计算谷歌表格上的加权平均值? - How can I calculate Weighted Average on google sheets based on a condition? 如何计算 Google 表格中的速率(每分钟事件数)? - How can I calculate rate (events per minute) in Google Sheets? 如何使用 Google 表格计算每天的平均利润 - How to calculate an average profit per day with Google Sheets 如何在 Google 表格中按司机计算平均每小时吨数? - How do I calculate average tons per hour by driver in Google Sheets? 如何在 Google 表格中突出显示基于今天()的月份行 - How can i highlight a Month row based on today() in Google Sheets 如何使用Google表格上的sumif根据月份/年份设置过滤器 - How can I set a filter based on month/year using sumif on google sheets 如何根据谷歌表格中的更多因素计算平均值 - How to calculate average based on more factors in google sheets 使用 Google 表格,如何根据条件将数据从一列转换为多行 - Using Google Sheets, how do I transpose data from one column into multiple rows based on conditions 如何用Google表格查询(按月分组)填充空白行? - How can I fill empty rows with google sheets query (group by month)? Google电子表格:如何计算一个月的平均值 - Google spreadsheet : How to calculate average considering a month
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM