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

How can I query multiple columns from a drop down menu and a count of a certain column

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

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

=QUERY(A2:O20,"SELECT M, count(M) Where E ='" &B23 & "' group by M",0)

我想以某种方式继续 select 某些列,并在用户从下拉菜单中 select 时显示它们,同时保留我当前的工作(从 M)

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

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

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

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

精简模式:

={"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)''")}


标记模式:

=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)}, )

注意:绿色背景和粗体标签可以通过条件格式auto-set


扩展模式:

=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.*", ""))