这是我的表:
Item | Person | Price
Shoes | John | $25
Clothes | John | $25
Pants | John | $50
Bags | Sarah | $50
Watch | Sarah | $150
Aftershave | John | $15
我已经设法将Person表作为教程后的下拉列表。
我知道想要另一个名为totals的列,它将根据用户计算总数:
Total Sarah:
Total John:
例如,它应该动态查找所有Sarah
并更新总数。我尝试过使用sumif
,但如果所选列中的所有行都与总数
sumif
这是我的样本表:
https://docs.google.com/spreadsheets/d/13MwyK-Suvvg9LfvzFcW-ojL9ilvb5OKCFjQwXgI4h70/edit?usp=sharing
我也试过
=query(sum(B:B,"count * where B ='John'" ,-1))
和
=sum(query(B:B, "select B where B='John'")+query(C:C, "select B,C where B='John'"))
答案 0 :(得分:1)
请清除列F:G和F1:
=query(A2:C30,"select B, sum(C) group by B")
在G9:=sum(G2:G6)
和格式适合。
答案 1 :(得分:1)
仅适用于Google表格:
={QUERY({A:C},"select Col2, sum(Col3) where Col2 <> '' group by Col2");"Total",SUM(C:C)}
{}
将范围A:C
转换为数组{A:C}
。这是为了在Col1, Col2...
中使用query
表示法。我更喜欢这个,因为范围字母A, B, C
可能会改变蚂蚁,这会导致公式崩溃。{array; value,calue}
来组合公式。这是link to documentation。