简体   繁体   English

如何使用单个公式计算条件中位数数组的平均值?

[英]How do I calculate the average from an array of conditional medians using a single formula?

I need to perform a 2-Step calculation in one formula.我需要在一个公式中执行两步计算。

The dataset contains several entries for each article and looks like that:数据集包含每篇文章的几个条目,如下所示:

在此处输入图片说明

As of now, I use a "helper"-column to obtain an array of conditional Medians first and calculate the average afterwards.截至目前,我使用“帮助器”列首先获取条件中位数数组,然后计算平均值。

Step 1: Calculate the Median %-Price Change per product.第 1 步:计算每种产品的价格变化中位数。

在此处输入图片说明

Step 2: Calculate the average from these Medians (counting each article once).第 2 步:计算这些中位数的平均值(对每篇文章计算一次)。

在此处输入图片说明

I would like to combine these two steps in one formula (ie by making use of dynamic array functions).我想将这两个步骤合并为一个公式(即通过使用动态数组函数)。

Thanks in advance.提前致谢。

I'm thinking maybe a helper column is easier.我在想也许辅助专栏更容易。 However, it can be done in O365 which my employer has kindly provided:但是,它可以在我的雇主提供的 O365 中完成:

=AVERAGE((INDEX(SORTBY(B:B,A:A,1,B:B,1),MATCH(UNIQUE(FILTER(A:A,A:A<>"")),A:A,0)+FLOOR((COUNTIF(A:A,UNIQUE(FILTER(A:A,A:A<>"")))-1)/2,1))+
INDEX(SORTBY(B:B,A:A,1,B:B,1),MATCH(UNIQUE(FILTER(A:A,A:A<>"")),A:A,0)+CEILING((COUNTIF(A:A,UNIQUE(FILTER(A:A,A:A<>"")))-1)/2,1)))/2)

So basically the match gives you an array of the row numbers where each group starts, and the floor/ceiling functions give you an offset from there to the mid-point of the sorted numbers within that group.所以基本上匹配会为您提供每个组开始的行号数组,并且地板/天花板函数为您提供从那里到该组内已排序数字的中点的偏移量。

See this for description of 'case-free' form of the median function.为中位功能“自由案例”的形式描述。

Assumes that the data is pre-sorted on the group letter, but not on the numbers within each group.假设数据是按组字母预排序的,而不是按每个组内的数字排序。

在此处输入图片说明

So Index now gives you an array without a hack - I didn't know that before attempting this.所以 Index 现在为您提供了一个没有 hack 的数组 - 在尝试之前我不知道这一点。

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

相关问题 如何在Excel中计算数组的平均斜率? - How do I calculate the average slope of an array in Excel? 使用数组公式来平均如果 - using array formula to average if 如何使用每隔两列使用2个单元格来计算公式? - How do i create a formula to calculate from using 2 cells, every other column? 如何使用公式计算每7个列的平均值? - How to calculate the average for every 7 colums with a formula? 我如何使用INT公式平均excel中E列中的D行? - How do I average D rows in E column in excel using INT formula? 如何使用 excel 数组公式获得取决于数量的平均 RATE? - How to get the average RATE depending on the amount by using excel array formula? 如何最好使用命令按钮来计算Excel中同一列中不同范围的平均值? - How do I calculate the average of different ranges in the same column in Excel preferably using command button? 如何在条件格式中合并Excel数组公式? - How can I incorporate Excel Array formula in Conditional Formatting? 需要一个数组公式来计算一列的平均值,不包括零 - Need an array formula to calculate average across a column, excluding zeroes 如果使用 excel 中的公式在其他列中匹配特定文本,如何计算关联列的平均值? - How to calculate average of a column associated if specific text matches in other column using formula in excel?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM