与Google Data Studio关联的Google表格文件示例:
Fruit |Color |Period |Amount
------------------------------
Apple |Green |201901 |3
Apple |Green |201902 |5
Apple |Red |201812 |5
Apple |Red |201903 |4
Grape |Red |201902 |4
Grape |Purple |201902 |6
Grape |Purple |201903 |1
例如,我想计算绿苹果和红苹果果实的总量。
所以公式应该是这样的:SUM Amount WHERE Fruit =“Apple”AND Color =“Green”OR Color =“Red”。在此示例中,总金额应为17
我试图在计算字段中使用此公式,但不幸的是,它不起作用:
SUM (Amount) WHERE (CASE WHEN Fruit = "Apple" AND Color = "Green" OR Color = "Red" ) then 1 else 0 END )
我收到语法错误。我怎么解决这个问题?