简体   繁体   English

计算过去 12 个月和 6 个月的平均值

[英]Calculate past 12 and 6 month Average

The excel user will export the data from an online website to excel (12 months data), so the data will be all the time different. excel 用户将数据从在线网站导出到 excel(12 个月数据),因此数据将始终不同。

I need the past 6 months and 12 months average ( However, the calculation need to use the months I have in the data, and sometimes there will be less then 6 or 12 months ), but I still need to get the average and frequency for it, however, I am not sure how to get it.我需要过去 6 个月和 12 个月的平均值但是,计算需要使用我在数据中的月份,有时会少于 6 或 12 个月),但我仍然需要获取平均值和频率但是,我不确定如何获得它。

I am trying to write a code, but it is not complete and is not working as well, I don't get an error;我正在尝试编写代码,但它不完整并且无法正常工作,我没有收到错误; it just doesn't work.它只是行不通。

I am open for Excel formulas as well, the problem may be the last row and that it need to use the data I have to calculate and not 6 and 12 months full.我也对 Excel 公式持开放态度,问题可能是最后一行,它需要使用我必须计算的数据,而不是 6 个月和 12 个月的完整数据。

PS: I post a similar question on https://www.ozgrid.com/forum/index.php?thread/1227312-dynamic-way-to-calculate-the-last-6-months-average/ PS:我在https://www.ozgrid.com/forum/index.php?thread/1227312-dynamic-way-to-calculate-the-last-6-months-average/上发布了一个类似的问题

Will This formulas work for you?这个公式对你有用吗? Average for last 6 months:过去 6 个月的平均值:

=AVERAGEIF(A:A;">="&EDATE(MAX(A:A);-6);B:B)

Frequency for last 6 months:过去 6 个月的频率:

=IF(MONTH(MAX(A:A)-MIN(A:A))>=6;COUNTIF(A:A;">="&EDATE(MAX(A:A);-6))/6;COUNTIF(A:A;">="&MIN(A:A))/MONTH(MAX(A:A)-MIN(A:A)))

Average for last 12 months:过去 12 个月的平均值:

=AVERAGEIF(A:A;">="&EDATE(MAX(A:A);-12);B:B)

Frequency for last 12 months:过去 12 个月的频率:

=IF(MONTH(MAX(A:A)-MIN(A:A))>=12;COUNTIF(A:A;">="&EDATE(MAX(A:A);-12))/12;COUNTIF(A:A;">="&MIN(A:A))/MONTH(MAX(A:A)-MIN(A:A)))

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM