根据列对行求和?

Sum the rows according the columns?

我有 table 看起来:

[![在此处输入图片描述][1]][1]

我需要根据日期求和,但有件事:

总和应该在新的table:

[![在此处输入图片描述][2]][2]

是否可以在没有宏的情况下在 excel 或 google 工作表中创建此公式?在这种情况下可以使用 if 和 sumifs 吗?

谢谢 [1]: https://i.stack.imgur.com/0D8u8.png [2]: https://i.stack.imgur.com/6gsAJ.png

尝试

=query(arrayformula(split(flatten(A2:B&"|"&C2:C),"|")),"select Col1,sum(Col2) where Col2 is not null group by Col1 label sum(Col2) 'total sum'",0)

编辑

=query({arrayformula(if(B2:B="",A2:A,B2:B)),C2:C},"select Col1,sum(Col2) where Col1 is not null group by Col1 label sum(Col2) 'total sum'",0)