计算某些文本组合在某些列中出现的次数
Count how many times certain text combinations occurs in certain columns
我有一个包含多列和大约 1000 行的数据集。我需要找出在数据集中可以找到特定列组合的次数。
在我下面的示例中,列 A:B
代表原始数据集。在 C2
中,我有一个公式可以从 A:B
列中找到所有非唯一组合。我需要的是一个计算列 C:D
中的组合在列 A:B
中出现的次数的公式。所需的输出应在 ColE
.
中
最好共享电子表格的副本,但请尝试输入 E1
={"Count"; ArrayFormula(IF(LEN(C2:C), VLOOKUP(C2:C&D2:D, query({A2:A&B2:B, A2:B}, "Select Col1, count(Col3) where Col1 <>'' group by Col1"), 2, 0),))}
看看是否可行?
请注意,您可以使用单个公式创建相同的输出(C、D 和 E 列)
=query(ArrayFormula(query({A2:B, A2:A&B2:B}, "Select Col1, Col2, count(Col3) where Col1 <>'' group by Col1, Col2")), "where Col3 >1 label Col1 'Value 1', Col2 'Value 2'")
您可以一次完成所有操作...删除 C、D、E 列并使用此公式:
=ARRAYFORMULA(QUERY({A2:B, A2:A&B2:B},
"select Col1,Col2,count(Col3)
where Col1 is not null
group by Col1,Col2
order by count(Col3) desc
label count(Col3)''"))
对于选定的组合,仅在 E2 单元格中使用此公式:
=ARRAYFORMULA(IFERROR(VLOOKUP(C2:C&D2:D, QUERY({A2:A&B2:B},
"select Col1,count(Col1)
where Col1 is not null
group by Col1
label count(Col1)''"), 2, 0)))
我有一个包含多列和大约 1000 行的数据集。我需要找出在数据集中可以找到特定列组合的次数。
在我下面的示例中,列 A:B
代表原始数据集。在 C2
中,我有一个公式可以从 A:B
列中找到所有非唯一组合。我需要的是一个计算列 C:D
中的组合在列 A:B
中出现的次数的公式。所需的输出应在 ColE
.
最好共享电子表格的副本,但请尝试输入 E1
={"Count"; ArrayFormula(IF(LEN(C2:C), VLOOKUP(C2:C&D2:D, query({A2:A&B2:B, A2:B}, "Select Col1, count(Col3) where Col1 <>'' group by Col1"), 2, 0),))}
看看是否可行?
请注意,您可以使用单个公式创建相同的输出(C、D 和 E 列)
=query(ArrayFormula(query({A2:B, A2:A&B2:B}, "Select Col1, Col2, count(Col3) where Col1 <>'' group by Col1, Col2")), "where Col3 >1 label Col1 'Value 1', Col2 'Value 2'")
您可以一次完成所有操作...删除 C、D、E 列并使用此公式:
=ARRAYFORMULA(QUERY({A2:B, A2:A&B2:B},
"select Col1,Col2,count(Col3)
where Col1 is not null
group by Col1,Col2
order by count(Col3) desc
label count(Col3)''"))
对于选定的组合,仅在 E2 单元格中使用此公式:
=ARRAYFORMULA(IFERROR(VLOOKUP(C2:C&D2:D, QUERY({A2:A&B2:B},
"select Col1,count(Col1)
where Col1 is not null
group by Col1
label count(Col1)''"), 2, 0)))