Google sheets 使用Google Sheets按年度划分收入';查询函数
我从财务部门获得每月收入数据,我可以将这些数据输入到报告格式中。它的月度数据在一列中列出了所有收入。我需要按年份(2018年、2019年等)划分收入 我相信我需要使用一个查询函数来解决这个问题,但是如果你有其他的解决方案,那么我也愿意接受 数据如下所示:Google sheets 使用Google Sheets按年度划分收入';查询函数,google-sheets,google-sheets-formula,google-sheets-query,Google Sheets,Google Sheets Formula,Google Sheets Query,我从财务部门获得每月收入数据,我可以将这些数据输入到报告格式中。它的月度数据在一列中列出了所有收入。我需要按年份(2018年、2019年等)划分收入 我相信我需要使用一个查询函数来解决这个问题,但是如果你有其他的解决方案,那么我也愿意接受 数据如下所示: Client Source Month Year Revenue abc Google 1 2019 100 abc Google 1
Client Source Month Year Revenue
abc Google 1 2019 100
abc Google 1 2018 100
abc Facebook 1 2018 50
abc Facebook 2 2018 50
Client Source Month 2018 Revenue 2019 Revenue
abc Google 1 100 100
abc Facebook 1 50 0
abc Facebook 2 50 0
我需要它看起来像这样:
Client Source Month Year Revenue
abc Google 1 2019 100
abc Google 1 2018 100
abc Facebook 1 2018 50
abc Facebook 2 2018 50
Client Source Month 2018 Revenue 2019 Revenue
abc Google 1 100 100
abc Facebook 1 50 0
abc Facebook 2 50 0
我熟悉查询函数,但我不知道该怎么做
这方面的伪代码类似于:
select Client,
Source,
Month,
Case when Year in 2019 then sum(Revenue) as 2019 Revenue else 0 end,
Case when Year in 2018 then sum(Revenue) as 2018 Revenue else 0 end
from Data
Group by Client, Source, Month
如果我需要提供任何其他信息,请告诉我。我感谢你在这个问题上的帮助
=QUERY(A1:E, "select A,B,C,sum(E) where A is not null group by A,B,C pivot D", 1)
哇,谢谢你!我不知道查询中存在pivot函数