如何从下拉菜单中查询多个列以及某个列的计数

时间:2019-05-28 21:24:47

标签: regex google-sheets array-formulas google-sheets-formula google-sheets-query

我正在尝试生成报告,以供用户从下拉菜单中进行选择。我希望能够从选定的下拉列表中拉出多个列。并且,如果可能的话,为特定的列获取一定的计数。

到目前为止,我只能选择一个列并从中获取计数。

    ../Frameworks/WebKit.framework/Versions/A/WebKit

我想以某种方式继续选择某些列,并在用户从下拉菜单中进行选择时显示它们,并保持我当前的工作(计数从M开始)

2 个答案:

答案 0 :(得分:1)

我设置了一个工作表副本,该副本根据从下拉列表中选择的值将每列的计数堆叠为报告。公式位于单元格K1中,我已将下拉列表移至单元格J1中:

https://docs.google.com/spreadsheets/d/1ccFgll7mW2rNs6m9gHUAx7ObsZ8n4GFjMc2cZS0nX68/edit?usp=sharing

公式的语法使用;将每个QUERY的输出放在下一个的顶部:

={QUERY(ColA);QUERY(ColB);QUERY(ColC);QUERY(ColE) etc...}

答案 1 :(得分:1)

紧凑模式:

={"select Interface", L1;
 QUERY(A2:H, "select A,count(A) where D='"&L1&"' group by A label count(A)''");
 QUERY(A2:H, "select B,count(B) where D='"&L1&"' group by B label count(B)''");
 QUERY(A2:H, "select C,count(C) where D='"&L1&"' group by C label count(C)''");
 QUERY(A2:H, "select E,count(E) where D='"&L1&"' group by E label count(E)''");
 QUERY(A2:H, "select F,count(F) where D='"&L1&"' group by F label count(F)''");
 QUERY(A2:H, "select G,count(G) where D='"&L1&"' group by G label count(G)''");
 QUERY(A2:H, "select H,count(H) where D='"&L1&"' group by H label count(H)''")}

0


标记模式:

=IF(K1<>"", {
 QUERY(A1:H, "select A,count(A) where D='"&K1&"' group by A label count(A)''", 1);
 QUERY(A1:H, "select B,count(B) where D='"&K1&"' group by B label count(B)''", 1);
 QUERY(A1:H, "select C,count(C) where D='"&K1&"' group by C label count(C)''", 1);
 QUERY(A1:H, "select E,count(E) where D='"&K1&"' group by E label count(E)''", 1);
 QUERY(A1:H, "select F,count(F) where D='"&K1&"' group by F label count(F)''", 1);
 QUERY(A1:H, "select G,count(G) where D='"&K1&"' group by G label count(G)''", 1);
 QUERY(A1:H, "select H,count(H) where D='"&K1&"' group by H label count(H)''", 1)}, )

0

注意:绿色背景和粗体标签可以通过条件格式自动设置


展开模式:

=ARRAYFORMULA(REGEXREPLACE(TO_TEXT(QUERY(A1:H, 
 "select A,count(A),B,count(B),C,count(C),D,count(D),
         E,count(E),F,count(F),G,count(G),H,count(H) 
  where D='"&K1&"' 
  group by A,B,C,D,E,F,G,H", 1)), "^count.*", ""))

0

0