值列表上的计算字段

Calculated field over list of values

鉴于此 table 数据:

我想制作这个支点 table:

我知道这可以通过计算字段和 SUMIF 来完成,但我无法让它工作。我认为主要的障碍是我无法找到好的文档来说明我可以在计算字段公式中引用的内容。我最好的尝试是 =SUMIF(color, "RED")/SUM(),但它产生了零。

示例 table 在 https://docs.google.com/spreadsheets/d/16htOLbwf47Neo68iFlm9OvFVS_u2Jlc-2thhdUQwrpU/edit?usp=sharing

感谢任何指导!

={QUERY(A1:B25,"select A,count(A)/"&COUNT(A:A)&" where B='RED' group by A label count(A)/"&COUNT(A:A)&" 'PCT RED'");{"Grand Total",COUNTIFS(A:A,">=0",B:B,"RED")/COUNT(A:A)}}

函数参考


I think my concern here would be that with a normal pivot table it's robust against data moving around. This seems to break that by referencing specific columns

方法枢轴table你必须显示所有颜色

I think my concern here would be that with a normal pivot table it's robust against data moving around. This seems to break that by referencing specific columns

到"set it free"你可以这样做:

={QUERY({A:B}, 
 "select Col1,count(Col1)/"&COUNT(A:A)&"
  where Col2='RED' 
  group by Col1 
  label count(Col1)/"&COUNT(A:A)&"'PCT RED'");
 {"Grand Total", COUNTIFS(A:A, ">=0", B:B, "RED")/COUNT(A:A)}}