你可以如何在Google Sheets中计算并显示列表中的最大重复项?

huangapple go评论65阅读模式
英文:

How can I count and show largest duplicate from a list in Google Sheets?

问题

最常用的作者:Cavan Scott
最不常用的作者:Shima Shinya

英文:

I am rather new to Excel (or SQL), and I was wondering how I could count and print the largest duplicate from a list.

Ex.: Lets say you have a list of authors:

Chris Rylander
Charles Soule
Justina Ireland
Claudia Gray
Cavan Scott
Multiple
Cavan Scott
Cavan Scott
Cavan Scott
Cavan Scott
Daniel José Older
Cavan Scott
Multiple
Multiple
Justina Ireland
Cavan Scott
Justina Ireland
Claudia Gray
Multiple
Daniel José Older
Cavan Scott
Cavan Scott
Shima Shinya

As you can see there are a lot of duplicates.
I would like to somehow extract the most used author from that list and the least used author from that list.

So the end results would be like this:
Most used author: Cavan Scott
Least used author: Shima Shinya

Could anyone help me with this problem please?

I tried with Count, Countif, but it returned numbers. Unfortunately thats the extend of my knowledge of google sheets.

答案1

得分: 3

= 在表格中,你可以尝试以下公式:

`=LAMBDA(x,y,{"最常用作者";FILTER(x,y=max(y));IFERROR(1/0);"最不常用作者";FILTER(x,y=min(y))})(UNIQUE(FILTER(A:A,A:A<>"")),INDEX(LAMBDA(z,COUNTIF(A:A,z))(UNIQUE(FILTER(A:A,A:A<>"")))))

  • 我有3个作者在“最不常用”下,而你提到了只有一个!

你可以如何在Google Sheets中计算并显示列表中的最大重复项?

如果你希望看到作者+计数(最大值、最小值)的公式:

`=LAMBDA(x,y,REDUCE({"作者","计数"},SEQUENCE(2),LAMBDA(a,c,{a;FILTER({x,y},y=INDEX({max(y);min(y)},c))})))(UNIQUE(FILTER(A:A,A:A<>"")),INDEX(LAMBDA(z,COUNTIF(A:A,z))(UNIQUE(FILTER(A:A,A:A<>""))))

使用查询:

最常用

`=QUERY(QUERY(A:A,"SELECT A, COUNT(A) WHERE A<>'' GROUP BY A ORDER BY COUNT(A) DESC LIMIT 1 LABEL COUNT(A)''"),"SELECT Col1")

最不常用

`=QUERY(QUERY(A:A,"SELECT A, COUNT(A) WHERE A<>'' GROUP BY A ORDER BY COUNT(A) LIMIT 1 LABEL COUNT(A)''"),"SELECT Col1")

如果新功能已经为你提供:

最常用

=LET(a,A:A,z,INDEX(COUNTIF(a,a)),+FILTER(a,z=max(z)))

最不常用

=LET(a,A:A,z,INDEX(COUNTIF(a,a)),+FILTER(a,z=MIN(FILTER(z,z&gt;0))))

你可以如何在Google Sheets中计算并显示列表中的最大重复项?

英文:

Within Sheets, you can try:

=LAMBDA(x,y,{&quot;Most Used Author&quot;;FILTER(x,y=max(y));IFERROR(1/0);&quot;Least Used Author&quot;;FILTER(x,y=min(y))})(UNIQUE(FILTER(A:A,A:A&lt;&gt;&quot;&quot;)),INDEX(LAMBDA(z,COUNTIF(A:A,z))(UNIQUE(FILTER(A:A,A:A&lt;&gt;&quot;&quot;)))))
  • I have 3 authors coming under Least used whilst you kinda mentioned just one!

你可以如何在Google Sheets中计算并显示列表中的最大重复项?

formula if wish to see the author+count(max, min)

=LAMBDA(x,y,REDUCE({&quot;Author&quot;,&quot;Count&quot;},SEQUENCE(2),LAMBDA(a,c,{a;FILTER({x,y},y=INDEX({max(y);min(y)},c))})))(UNIQUE(FILTER(A:A,A:A&lt;&gt;&quot;&quot;)),INDEX(LAMBDA(z,COUNTIF(A:A,z))(UNIQUE(FILTER(A:A,A:A&lt;&gt;&quot;&quot;)))))

USING QUERY:

Most Used

=QUERY(QUERY(A:A,&quot;SELECT A, COUNT(A) WHERE A&lt;&gt;&#39;&#39; GROUP BY A ORDER BY COUNT(A) DESC LIMIT 1 LABEL COUNT(A)&#39;&#39;&quot;),&quot;SELECT Col1&quot;)

Least Used

=QUERY(QUERY(A:A,&quot;SELECT A, COUNT(A) WHERE A&lt;&gt;&#39;&#39; GROUP BY A ORDER BY COUNT(A) LIMIT 1 LABEL COUNT(A)&#39;&#39;&quot;),&quot;SELECT Col1&quot;)

Incase the new functions have rolled out for you, use:

Most Used

=LET(a,A:A,z,INDEX(COUNTIF(a,a)),+FILTER(a,z=max(z)))

Least Used

=LET(a,A:A,z,INDEX(COUNTIF(a,a)),+FILTER(a,z=MIN(FILTER(z,z&gt;0))))

你可以如何在Google Sheets中计算并显示列表中的最大重复项?

答案2

得分: 1

以下是已翻译的内容:

  1. 查找唯一值 =unique(range)
  2. 计算出现次数 =countif(unique_values, list_unique)
  3. 返回具有最大出现次数的唯一值 =INDEX(list_unique; MATCH(LARGE(list_number_occurrence;1); list_number_occurrence; 0))
英文:

I would would solve in the following way:

  1. Find unique values =unique(range)
  2. Count the occurrence =contif(unique_values,list_unique)
  3. return the unique value with max occurrence =INDEX(list_unique; MATCH(LARGE(list_number_occurence;1); list_number_occurence; 0))

你可以如何在Google Sheets中计算并显示列表中的最大重复项?

答案3

得分: 1

你可以尝试:

你可以如何在Google Sheets中计算并显示列表中的最大重复项?

B1 单元格中的公式:

`=LAMBDA(a,UNIQUE(SORT(FILTER({a,COUNTIF(a,a)},(COUNTIF(a,a)=MAX(COUNTIF(a,a)))+(COUNTIF(a,a)=MIN(COUNTIF(a,a)))),2,0)))(FILTER(A:A,A:A<>""))

希望随着 LET() 的引入,这将变得更加容易。

英文:

You could try:

你可以如何在Google Sheets中计算并显示列表中的最大重复项?

Formula in B1:

=LAMBDA(a,UNIQUE(SORT(FILTER({a,COUNTIF(a,a)},(COUNTIF(a,a)=MAX(COUNTIF(a,a)))+(COUNTIF(a,a)=MIN(COUNTIF(a,a)))),2,0)))(FILTER(A:A,A:A&lt;&gt;&quot;&quot;))

Let's hope with the comming of LET() this gets a lot easier.

huangapple
  • 本文由 发表于 2023年2月6日 21:35:37
  • 转载请务必保留本文链接:https://go.coder-hub.com/75361994.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定