[英]From several sets of data, sum the highest numbers for each Id
I have 3 sets of data, all consisting of 1 column with a list of unique IDs and the other with integers. 我有3组数据,所有数据都包含1列,其中包含唯一ID列表,另一列包含整数。 Some of the unique IDs (with their integer) appear in more than 1 set, others don't.
一些唯一ID(带有整数)出现在1组以上,有些则不出现。
ColA ColB ColD ColE ColF ColG
UniqueIDs1 Integers1 UniqueIDs2 Integers2 UniqueIDs3 Integers3
I want to sum all the integers in all sets, BUT if there's a duplicate, only sum the highest between the 3 (or the 2 if the match is only between 2 sets). 我想对所有集合中的所有整数求和,但是如果有重复,则只有3之间的最高值(如果匹配仅在2集之间则为2)。
How can I do that? 我怎样才能做到这一点?
The following formula computes such a sum. 以下公式计算这样的总和。
=sum(query({A:B; D:E; F:G}, "select max(Col2) group by Col1"))
{A:B; D:E; F:G}
{A:B; D:E; F:G}
stacks the columns of your sheet (you may want to use A2:B if 1st row are headers). {A:B; D:E; F:G}
堆叠工作表的列(如果第一行是标题,则可能需要使用A2:B)。 The result is an array with two columns, Id in Col1, and integer in Col2. Query
selects the maximal element of second column for each Id. Query
为每个Id选择第二列的最大元素。 Sum
adds those. Sum
添加了那些。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.