【问题标题】:How to find the most frequent text value in a whole spreadsheet on Google sheets?如何在 Google 表格的整个电子表格中找到最常见的文本值?
【发布时间】:2021-03-26 03:51:33
【问题描述】:

我知道在单个列中查找最频繁值的代码,但我正在尝试找出让我在多个特定列中查找最频繁值的代码。

例如: =ARRAYFORMULA(索引(A2:A17,MATCH(MAX(COUNTIF(A2:A17,A2:A17)),COUNTIF(A2:A17,A2:A17),0)))

^^这个公式只允许我有两个 COUNTIF 参数

=INDEX(A2:A6,MODE(MATCH(A2:A6,A2:A6,0)))

^^这个只允许索引中最多 4 个参数

我想要一个等式,它可以让我找到 16 个特定列的最常用文本值。

这可能吗?

【问题讨论】:

    标签: google-sheets google-sheets-formula


    【解决方案1】:

    更好的公式

    你要求公式when you have 2 top values with the same frequency

    =SORTN(QUERY(FLATTEN(H2:K),
             "select Col1, count(Col1) 
              where Col1 is not null group by Col1 
              order by count(Col1) desc label count(Col1) '' ",0),1,1,2,0)
    


    第一个答案

    仅使用 1 个QUERY 公式

    追求价值

    =QUERY(FLATTEN(A2:D),
             "select Col1, count(Col1) 
              where Col1 is not null group by Col1 
              order by count(Col1) desc limit 1",0)
    

    对于所有值

    =QUERY(FLATTEN(A2:D),
             "select Col1, count(Col1) 
              where Col1 is not null group by Col1 
              order by count(Col1) desc limit 1",0)
    

    【讨论】:

    • 当你有两个相同频率的最高值时,情况如何?
    • @KrzysztofDołęgowski 查看更好的公式
    【解决方案2】:

    我分两步展示它,然后在一个公式中将步骤组合在一起: 首先,您将表格展平并删除重复项以获取一列您检查频率的值:

    unique(flatten(B2:I25))
    

    然后为每个检查出现次数:

    ArrayFormula(countif($B$2:$I$25,unique(flatten(B2:I25))))
    

    然后您必须过滤新表并仅获取具有最高值的行:

    =filter({first , second column};second column = max(second column)
    

    使用较早的值:

    =filter({unique(flatten(B2:I25)),ArrayFormula(countif($B$2:$I$25,unique(flatten(B2:I25))))},ArrayFormula(countif($B$2:$I$25,unique(flatten(B2:I25))))=max(ArrayFormula(countif($B$2:$I$25,unique(flatten(B2:I25))))))
    

    我的解决方案在这里可用: https://docs.google.com/spreadsheets/d/1gMZDFWOY8qbA1Bhp8rZ_por3Skb0i_qQtlaSlCTKXgM/copy

    如果您的列分散在工作表周围,您应该使用 { } 并为它们制作一个表格。

    【讨论】:

    • 非常感谢!非常有帮助:)))))
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-04-03
    • 2017-10-10
    • 2016-07-03
    • 2011-12-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多