简体   繁体   English

单元格中的动态平均(Excel 2016)

[英]Dynamically Average in Cell (Excel 2016)

I have problem with dynamically average calcuation. 我对动态平均计算有疑问。

在此处输入图片说明

...after adding (I change Average manually) ...添加后(我手动更改了平均值)

在此处输入图片说明

In my Excel file I have users with some values and I'm every month adding new values and there is also Average that must increase. 在我的Excel文件中,我的用户具有一些值,我每个月都在添加新值,并且还必须增加“平均值”。 Now I edit this manually but I want to do that automatically. 现在,我手动进行编辑,但我想自动进行。 Is it possible? 可能吗? How should be the formula for this? 公式应该如何?

Note that I cannot move cells. 请注意,我无法移动单元格。

First of all move the column with the average to a place where you don't need to move it anymore. 首先,将具有平均值的列移动到不再需要移动的位置。 Probably P column if you need to get all months in there. 如果您需要整整几个月的时间,可能是P列。

Then in the P2 cell add this formula 然后在P2单元格中添加此公式

=SUM(D2:O2)/COUNT(D2:O2)  

This will first sum the range and then divide by the number of entries you have in the range. 这将首先对范围求和,然后除以您在该范围中拥有的条目数。

However, this part: also Average that must increase is nothing that a formula can handle. 但是,这部分内容: also Average that must increase也不是公式可以处理的。
It will only calculate the average, sometimes it may increase and sometimes it will decrease. 它只会计算平均值,有时可能会增加,有时会减少。

As stated above, you should move the average calculation else where. 如上所述,您应该将平均计算结果移动到其他位置。

Another approach is to create a named ranges. 另一种方法是创建一个命名范围。

For John, we will use following formula for named range definition and call it JohnAvg , this is generic formula for dynamic range, it will expand for the defined line automatically, considering you have only the months data you want to average there: 对于John,我们将使用以下公式来命名范围定义,并将其称为JohnAvg ,这是动态范围的通用公式,考虑到只有平均月份的数据,它将自动为定义的行扩展:

=$D$2:INDEX($2:$2;COUNTA($2:$2))

Then, the formula for calculating John's average is: 然后,计算约翰平均值的公式为:

=AVERAGE(JohnAvg)
=AVERAGE(OFFSET(F2,0,4-COLUMN(),1,COLUMN()-4))

(Written to start in cell F2 ) (写在F2单元格中开始)

This will use OFFSET to create a Range that starts in Column 4 (D) and extends until the Column before the Cell that the formula is written in. 这将使用OFFSET创建一个范围,该范围从第4列(D)开始,一直延伸到写入公式的单元格之前的列。

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

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