简体   繁体   English

使用 ARRAYFORMULA 检测 Google 表格中的重复项

[英]Detecting Duplicates in a Google Sheet with ARRAYFORMULA

I'm trying to build a Google Sheet that looks like this:我正在尝试构建一个如下所示的 Google 表格:

+-------------------+-----------+
|Email              |Duplicate? |
+-------------------+-----------+
|banana@example.com |No         |
|orange@example.com |No         |
|peach@example.com  |No         |
|banana@example.com |Yes        |
|banana@example.com |Yes        |
|apple@example.com  |No         |
|peach@example.com  |Yes        |
+-------------------+-----------+

In my example, the first column is filled in manually with some email addresses.在我的示例中,第一列手动填写了一些 email 地址。 The second column should be a formula that returns Yes if the value has been duplicated previously in the column, and No if it hasn't.第二列应该是一个公式,如果该值先前在该列中重复,则返回Yes ,如果没有,则返回No

So far, I've trying to use VLOOKUP and INDIRECT inside of ARRAYFORMULA to accomplish this.到目前为止,我尝试在ARRAYFORMULA中使用VLOOKUPINDIRECT来完成此操作。 If I can get that to successfully return a value, then I can build the IF around it to return the strings I want.如果我可以让它成功返回一个值,那么我可以围绕它构建IF以返回我想要的字符串。 However, this doesn't work.但是,这不起作用。

=ARRAYFORMULA(VLOOKUP(B2:B, INDIRECT("B1:B" & ROW(B2:B) - 1), 1, FALSE))

I've also tried using COUNTIF , but that doesn't seem to be playing nice with ARRAYFORMULA either.我也尝试过使用COUNTIF ,但这似乎也不适用于ARRAYFORMULA

I'd really appreciate some insight here on what I'm missing.我真的很感激这里对我所缺少的东西的一些见解。 Am I thinking about ARRAYFORMULA wrong?我在想ARRAYFORMULA错了吗? Does INDIRECT not work the way I think it does? INDIRECT不会像我认为的那样工作吗?

try:尝试:

=ARRAYFORMULA(IF(A1:A<>"", IF(
 (COUNTIFS(A1:A, A1:A, ROW(A1:A), "<="&ROW(A1:A))>1)*
 (COUNTIF( A1:A, A1:A)>1), "yes", "no"), ))

在此处输入图像描述

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

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