我在Google表格中显示了一些值,如下所示。
Name Answer
A yes
A No
B No
A Yes
X Yes
A Yes
我想聚合这些值并将结果显示在另一个表中,如下所示:
Name Total Right Wrong Right%
A 4 3 1 75
B 1 0 1 0
X 1 1 0 100
如何使用电子表格公式执行此操作?
答案 0 :(得分:1)
看看this example sheet 我使用这个公式来生成所需的输出
=query(ArrayFormula(if(len(query({filter(Sheet1!A2:B, len(Sheet1!B2:B)),filter(ArrayFormula(if(Sheet1!B2:B="yes", "Right", "Wrong")), len(Sheet1!B2:B))}, "select Col1, count(Col2) group by Col1 pivot Col3"))=0, 0, (query({filter(A2:B, len(Sheet1!B2:B)),filter(ArrayFormula(if(Sheet1!B2:B="yes", "Right", "Wrong")), len(Sheet1!B2:B))}, "select Col1, count(Col2) group by Col1 pivot Col3")))), "select Col1, (Col2+Col3)*1, Col2, Col3, (Col2/(Col2+Col3))*100 label (Col2+Col3)*1 'Total', (Col2/(Col2+Col3))*100 'Right %', Col1 'Names' ")