在另一张纸上试试这个,第 1 行:
=arrayformula(query({query({Sheet1!$A:$C},"order by Col1 desc,Col2",1),{"Dupe position";countifs(query({Sheet1!$A2:$C},"select Col2 order by Col1 desc,Col2",0),query({Sheet1!$A2:$C},"select Col2 order by Col1 desc,Col2",0),row(Sheet1!$A2:$C),"<="&row(Sheet1!$A2:$C))}},"select Col1,Col2,Col3 where Col1 is not null and Col4 <= 10 order by Col1",1))
您可以通过调整Col4 <= 10来调整找到的记录数,也可以通过更改公式末尾的order by Col1来调整最终排序。
说明
这从 Sheet1 获取数据,按日期 desc 排序,然后通过电子邮件 asc:
query({Sheet1!$A:$C},"order by Col1 desc,Col2",1)
然后在该数据的旁边,COUNTIFS() 用于获取每次电子邮件出现在上面的列表中时的数字(因为它是降序排序的,1 代表最近的实例)。
countifs(<EmailColumnData>,<EmailColumnData>,row(<EmailColumn>),"<="&row(<EmailColumn>))
COUNTIF() 中的<EmailColumnData> 是:
query({Sheet1!$A2:$C},"select Col2 order by Col1 desc,Col2",0)
代替上面的<EmailColumn>,我们只需要行号,所以我们不需要实际数据。我们可以用:
Sheet1!$A2:$C
各种{} 作为数组将数据汇集在一起。
例如,{a,b,c;d,e,f} 将产生三列,a, b, c 在第 1 行,d, e, f 在第 2 行。, 是一个新列,; 是一个新行的返回。
对所有内容的最终查询得到我们需要的 3 列,其中 col 4 中的计数为