Google 计算列中唯一值出现次数的工作表公式
Google Sheets Formula to Count Occurrences of Unique Values in Columns
我正在寻找一个公式,可能 =query,它会变成这样:
进入这个:
我使用下面的公式成功得到了AFTER图片,但是我无法得到计数。我尝试使用连接但没有办法对数组中的每个项目执行此操作。也许有一种方法可以使用查询来做到这一点?
=transpose(split(join(",",unique(C1:C98)),","))
在单元格 A2
中尝试以下操作并向右拖动。
=ARRAY_CONSTRAIN(ArrayFormula(IFERROR(CONCAT(UNIQUE(A2:A99)&" - ",
ArrayFormula(COUNTIFS(A2:A99,UNIQUE(A2:A99)))))),COUNTUNIQUE(A2:A99),1)
也使用查询
=ArrayFormula(index(query({A2:A},"select Col1,count(Col1) where Col1 is not null group by Col1 label count(Col1) ''"),0,1)&"-"&
index(query({A2:A},"select Col1,count(Col1) where Col1 is not null group by Col1 label count(Col1) ''"),0,2))
唯一的区别是,使用第一个公式,您可以按照它们出现的顺序维护名称,而使用查询,它们将按字母顺序排序。
使用的函数:
是的,您可以使用查询来获取唯一值和计数,然后连接两列
=ArrayFormula(index(query(A2:A,"select A,count(A) where A is not null group by A label count(A) ''"),0,1)&"-"&index(query(A2:A,"select A,count(A) where A is not null group by A label count(A) ''"),0,2))
抱歉,要将其拖过,您必须输入:
=ArrayFormula(index(query({A2:A},"select Col1,count(Col1) where Col1 is not null group by Col1 label count(Col1) ''"),0,1)
&"-"&index(query({A2:A},"select Col1,count(Col1) where Col1 is not null group by Col1 label count(Col1) ''"),0,2))
这是我的风格,也需要向右拖动以填充其他列:
=ARRAYFORMULA(QUERY(
{UNIQUE(A:A) & " - " & COUNTIF(A:A,UNIQUE(A:A))},
"where Col1<>' - 0'",0))
我正在寻找一个公式,可能 =query,它会变成这样:
进入这个:
我使用下面的公式成功得到了AFTER图片,但是我无法得到计数。我尝试使用连接但没有办法对数组中的每个项目执行此操作。也许有一种方法可以使用查询来做到这一点?
=transpose(split(join(",",unique(C1:C98)),","))
在单元格 A2
中尝试以下操作并向右拖动。
=ARRAY_CONSTRAIN(ArrayFormula(IFERROR(CONCAT(UNIQUE(A2:A99)&" - ",
ArrayFormula(COUNTIFS(A2:A99,UNIQUE(A2:A99)))))),COUNTUNIQUE(A2:A99),1)
也使用查询
=ArrayFormula(index(query({A2:A},"select Col1,count(Col1) where Col1 is not null group by Col1 label count(Col1) ''"),0,1)&"-"&
index(query({A2:A},"select Col1,count(Col1) where Col1 is not null group by Col1 label count(Col1) ''"),0,2))
唯一的区别是,使用第一个公式,您可以按照它们出现的顺序维护名称,而使用查询,它们将按字母顺序排序。
使用的函数:
是的,您可以使用查询来获取唯一值和计数,然后连接两列
=ArrayFormula(index(query(A2:A,"select A,count(A) where A is not null group by A label count(A) ''"),0,1)&"-"&index(query(A2:A,"select A,count(A) where A is not null group by A label count(A) ''"),0,2))
抱歉,要将其拖过,您必须输入:
=ArrayFormula(index(query({A2:A},"select Col1,count(Col1) where Col1 is not null group by Col1 label count(Col1) ''"),0,1)
&"-"&index(query({A2:A},"select Col1,count(Col1) where Col1 is not null group by Col1 label count(Col1) ''"),0,2))
这是我的风格,也需要向右拖动以填充其他列:
=ARRAYFORMULA(QUERY(
{UNIQUE(A:A) & " - " & COUNTIF(A:A,UNIQUE(A:A))},
"where Col1<>' - 0'",0))