You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

求助:Google Sheets无AGGREGATE函数,如何替代Excel原公式实现排序匹配

Fixing the AGGREGATE Function Gap in Google Sheets

Since Google Sheets doesn’t support Excel’s AGGREGATE function, let’s replicate exactly what your original formula was doing with native Google Sheets tools. Your original formula pulled the Nth matching value from column V (where N is the number of times the current Y value has appeared so far) based on matches in column W. Here are two reliable solutions:

Solution 1: INDEX + SMALL + FILTER (Closest to Original Logic)

This breaks down the AGGREGATE(15,6,...) logic into Google Sheets-compatible parts:

  • FILTER(ROW($2:$14), W$2:$14=Y2) grabs all row numbers where column W matches the current Y value
  • SMALL(..., COUNTIF(Y$2:Y2, Y2)) picks the Nth smallest row number (N counts how many times Y2 has shown up up to the current row)
  • INDEX(V:V, ...) pulls the corresponding value from column V

Use this formula in cell Z2, then drag it down the column:

=INDEX(V:V, SMALL(FILTER(ROW($2:$14), W$2:$14=Y2), COUNTIF(Y$2:Y2, Y2)))

Solution 2: QUERY Function (More Readable)

If you prefer a cleaner approach, the QUERY function can filter matching values first, then we pick the Nth result with INDEX:

For text values in Y column:

=INDEX(QUERY($V$2:$W$14, "SELECT V WHERE W = '"&Y2&"'", 0), COUNTIF(Y$2:Y2, Y2))

For numeric values in Y column:

Remove the single quotes around Y2 (QUERY handles numbers differently):

=INDEX(QUERY($V$2:$W$14, "SELECT V WHERE W = "&Y2&"", 0), COUNTIF(Y$2:Y2, Y2))

Both solutions will preserve the order from column W and correctly handle duplicate values in Y—just like your original Excel formula did. Test them with your dataset to confirm they work as expected!

内容的提问来源于stack exchange,提问作者Camilo Quevedo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 06:48:34