Google 工作表查询公式中的数据列

Data Cols in Google Sheets Query Formula

我想做的是创建一个查询公式,按商店过滤的周数返回年销售额。

示例 sheet:Link

使用像这样的公式很容易做到:=Query(query(A:D,"Select A,Sum(D) where A is not null group by A Pivot B",1),"Select * offset 1",0)

但我还需要根据特定商店 (Col C) 过滤结果

也不难: =Query(query(A:D,"Select A,Sum(D) where C = 'First' AND A is not null group by A Pivot B",1),"Select * offset 1",0)

但在这种情况下,任何销售额为 0 且商店等于 'Second' 的一周都将被忽略。

我想显示数据中出现的所有星期(A 列)。可能吗?

尝试:

=ARRAYFORMULA(QUERY(QUERY({A:B, IF(C:C<>"First", {"First", 0}, C:D)}, 
 "select Col1,sum(Col4) 
  where Col3 = 'First' 
    and Col1 is not null 
  group by Col1 
  pivot Col2"), "offset 1", 0))