[英]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.