简体   繁体   English

谷歌表格 - 在数组公式中找到第一个匹配项

[英]Google Sheets - finding first match in array formula

Okay, I found many solution for many problems in Google Sheets, but this one is just hard as a rock.好的,我在 Google Sheets 中找到了许多问题的解决方案,但这个问题就像一块石头一样坚硬。 :) :)

I have a sheet where in column C are various names and in column D are professions.我有一张表格,其中 C 列中有各种名称,而 D 列中有职业。 For example:例如:

C / D
John Smith / plumber
Paul Anderson / carpenter
Sarah Palmer / dentist
Jonah Huston / carpenter
Laura Jones / dentist
Sid Field / carpenter
...etc

(as you can see every name are identical, but professions are repeating several times) (你可以看到每个名字都是一样的,但是职业重复了好几次)

I'd like to see in column F the last matching name of the same profession我想在 F 列中看到同一职业的最后一个匹配名称

C / D / F
John Smith / plumber / (N/A)
Paul Anderson / carpenter /Jonah Huston
Sarah Palmer / dentist / Laura Jones
Jonah Huston / carpenter / Sid Field
Laura Jones / dentist / (N/A)
Sid Field / carpenter / (N/A)
...etc

It works fine with INDEX and FILTER function, but I have to copy the code over and over again as I add extra rows.它适用于 INDEX 和 FILTER function,但是当我添加额外的行时,我必须一遍又一遍地复制代码。 This is the code I use:这是我使用的代码:

=IFERROR(INDEX(FILTER($C4:$C,$D4:$D=D6,$A4:$A<A6),1))

I'm looking for a solution with Array Formula to autofill all cells in column F, and tried various versions (Lookup, Vlookup..etc), but couldn't find the right formula.我正在寻找使用 Array Formula 自动填充 F 列中所有单元格的解决方案,并尝试了各种版本(Lookup、Vlookup..etc),但找不到正确的公式。

Any guidance would be appreciated.任何指导将不胜感激。 :) :)

try:尝试:

=INDEX(IF(C1:C="",,IFNA(VLOOKUP(
 D1:D&COUNTIFS(D1:D, D1:D, ROW(D1:D), "<="&ROW(D1:D)), {
 D1:D&COUNTIFS(D1:D, D1:D, ROW(D1:D), "<="&ROW(D1:D))-1, 
 C1:C}, 2, 0), "(N/A)")))

在此处输入图像描述

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM