简体   繁体   English

从excel表格中计算动态平均值

[英]Calculate a dynamic average from a table in excel

I have this table of currency rates:我有这张汇率表: 在此处输入图片说明

I would like to create a formula that receives the begin date and end date + currency, and in return will calculate the average for every month inside the range.我想创建一个公式来接收开始日期和结束日期 + 货币,作为回报,将计算该范围内每个月的平均值。

For example, if the currency is GBP, begin date is 15/09/2015 and end date is 20/11/2015, I would like to calculate averages for 30/09/2015 + 31/10/2015 + 30/11/2015.例如,如果货币是英镑,开始日期是 15/09/2015,结束日期是 20/11/2015,我想计算 30/09/2015 + 31/10/2015 + 30/11/ 2015 年。

I tried to solve it with a simple Average + Vlookup + Match functions, but it wouldn't get me the range of cells but only the edges of the range.我试图用一个简单的平均 + Vlookup + 匹配函数来解决它,但它不会让我得到单元格的范围,而只能得到范围的边缘。 I also thought of using AverageIF function, but I'm not sure how to combine between the criterias of date and currency.我也想过使用AverageIF函数,但我不确定如何结合日期和货币的标准。

Can you think of an easy way to solve that?你能想出一个简单的方法来解决这个问题吗?

I suggest using an index/match to get a reference to the beginning of the range of currencies then another one to get the end of the range and combining them like this:-我建议使用索引/匹配来获取对货币范围开头的引用,然后使用另一个引用来获取范围的结尾并像这样组合它们:-

=AVERAGE(INDEX($B$2:$H$10,MATCH(D13,A$2:A$10,0),MATCH(1,(MONTH(E13)=MONTH($B$1:$H$1))*(YEAR(E13)=YEAR($B$1:$H$1)),0)):
INDEX($B$2:$H$10,MATCH(D13,A$2:A$10,0),MATCH(1,(MONTH(F13)=MONTH($B$1:$H$1))*(YEAR(F13)=YEAR($B$1:$H$1)),0))
)

Where the currency name is in D13, start date in E13 and end date in F13, and the table is in A1:H10.其中货币名称在D13,开始日期在E13,结束日期在F13,表格在A1:H10。

Result: 1.5203结果:1.5203

Must be entered as an array formula using Ctrl Shift Enter必须使用Ctrl Shift Enter作为数组公式输入

Found a way to solve this, by using the AVERAGEIF function.通过使用 AVERAGEIF 函数找到了解决此问题的方法。 Enjoy, and thanks for helping!享受,并感谢您的帮助!

在此处输入图片说明

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

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