简体   繁体   English

Excel-计算月份的平均值,从单元格引用中的月份开始

[英]Excel - Calculate average across months, starting from month in cell reference

I have a sheet where each row is one user, column O shows the date the user record was created, columns R to AE show the number of logins each user has per month, June 2017 to July 2018. 我有一张工作表,其中每一行都是一个用户,O列显示创建用户记录的日期,R列到AE列显示每个用户每月的登录数量,即2017年6月至2018年7月。

The goal is to only calculate an average of logins for months >= the month the user was created. 目标是仅计算大于等于创建用户月份的月份的平均登录次数。 If the user has a Created On date value less than 1 June 2017, average all the monthly columns R to AE. 如果用户的“创建日期”值小于2017年6月1日,则将所有月度列R到AE平均。

Example 1: A user was created on 24 November 2017, therefore I only want to average logins of the month columns from November 2017 onwards. 示例1:一个用户于2017年11月24日创建,因此,我只想平均从2017年11月开始的月份列登录。

Example 2: A user was created August 2013, therefore I want to average all month columns (June 2017 to July 2018, R to AE). 示例2:一个用户创建于2013年8月,因此我想平均所有月份的列(2017年6月至2018年7月,R到AE)。

I tried using Index Match, though can't figure out how to select the range. 我尝试使用索引匹配,尽管无法弄清楚如何选择范围。

Link to file 链接到文件

Use =SUM(R2:AE) to add the logins to get total login. 使用=SUM(R2:AE)添加登录名以获取总登录名。

Use =DATEDIF(A2, "July 2018", "M") to get the number of months. 使用=DATEDIF(A2, "July 2018", "M")获得月份数。 First argument of DATEDIF is initial date, second argument is final date and "M" signifies that we want number of months as the output DATEDIF第一个参数是初始日期,第二个参数是最终日期, "M"表示我们希望将月数作为输出

Divide the total login by number of months to get the average. 将登录总数除以月份数即可得出平均值。

link to google sheet file 链接到Google工作表文件

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

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