英文:
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个作者在“最不常用”下,而你提到了只有一个!
如果你希望看到作者+计数(最大值、最小值)的公式:
`=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>0))))
英文:
Within Sheets, you can try:
=LAMBDA(x,y,{"Most Used Author";FILTER(x,y=max(y));IFERROR(1/0);"Least Used Author";FILTER(x,y=min(y))})(UNIQUE(FILTER(A:A,A:A<>"")),INDEX(LAMBDA(z,COUNTIF(A:A,z))(UNIQUE(FILTER(A:A,A:A<>"")))))
- I have 3 authors coming under
Least used
whilst you kinda mentioned just one!
formula if wish to see the author+count(max, min)
=LAMBDA(x,y,REDUCE({"Author","Count"},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<>"")))))
USING QUERY:
Most Used
=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")
Least Used
=QUERY(QUERY(A:A,"SELECT A, COUNT(A) WHERE A<>'' GROUP BY A ORDER BY COUNT(A) LIMIT 1 LABEL COUNT(A)''"),"SELECT Col1")
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>0))))
答案2
得分: 1
以下是已翻译的内容:
- 查找唯一值
=unique(range)
- 计算出现次数
=countif(unique_values, list_unique)
- 返回具有最大出现次数的唯一值
=INDEX(list_unique; MATCH(LARGE(list_number_occurrence;1); list_number_occurrence; 0))
英文:
I would would solve in the following way:
- Find unique values
=unique(range)
- Count the occurrence
=contif(unique_values,list_unique)
- return the unique value with max occurrence
=INDEX(list_unique; MATCH(LARGE(list_number_occurence;1); list_number_occurence; 0))
答案3
得分: 1
你可以尝试:
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()
的引入,这将变得更加容易。
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论