在不使用谷歌表格数据透视表功能的情况下创建表格

问题描述 投票:0回答:1

如何转换以下有关购买的实时数据(通过链接的谷歌表单收集):

时间戳 价格 具体类别 日期值 日期 年份 星期几
2024年4月15日13:49:34 200 礼物 45397 15/04 2024 周一
2024年4月15日13:49:44 65 晚餐 45397 15/04 2024 周一
2024年4月16日13:49:54 14 午餐 45398 16/04 2024 周二
4/16/2024 13:50:02 5 零食 45398 16/04 2024 周二
2024年4月16日14:50:02 3 零食 45398 16/04 2024 周二
2024年4月17日13:50:18 8 交通 45399 17/04 2024 周三
2024年4月17日13:50:25 14 零食 45399 17/04 2024 周三
2024年4月18日13:50:36 14 早餐 45400 18/04 2024 周四
2024年4月18日13:50:42 15 午餐 45400 18/04 2024 周四
2024年4月19日13:50:50 19 晚餐 45401 19/04 2024 周五
2024年4月20日13:51:00 7 材料 45402 20/04 2024 周六
2024年4月20日13:51:09 5 零食 45402 20/04 2024 周六
4/21/2024 13:51:22 30.8 午餐 45403 21/04 2024 太阳
4/21/2024 13:51:33 8 零食 45403 21/04 2024 太阳

进入 google Sheets 中如下所示的表格,而不使用数据透视表功能?

Output table

重要的是:

  1. 每当数据更新时,表都需要更新
  2. 每个单元格的值应该是相应日期相应类别的支出总和(例如,16/4 的零食花费了 5 美元和 3 美元,因此总计报告为 8 美元)
  3. 当新的日期添加到数据中时,它们也会添加到表中
  4. 当新类别添加到数据中时,它们将被添加到表格中

我是 Google Sheets/Excel 的新手,因此对任何潜在解决方案的解释将不胜感激(我有相当多的编程经验,因此不必非常详细)。

google-sheets google-sheets-formula
1个回答
0
投票

尝试一下:

=ArrayFormula(let(
liveData,{Source!A:C,weeknum(Source!A:A,2)},
pvt,transpose(query(liveData,"select Col1,sum(Col2) where Col1 is not null and Col3 is not null group by Col1 pivot Col3 label Col1 'Specific category' format Col1 'yyyy-mm-dd'",1)),
dow,iferror(if(to_date(chooserows(pvt,1)),text(chooserows(pvt,1),"ddd"),)),
dayTtl,{"TOTALS",chooserows(query(liveData,"select sum(Col2) where Col1 is not null and Col3 is not null pivot Col1",1),2)},
wkTtlHlp,query(liveData,"select max(Col1),sum(Col2) where Col1 is not null and Col3 is not null group by Col4 label max(Col1) 'Specific category', sum(Col2) 'WEEKLY TOTALS'",1),
wkTtl,ifna(vlookup(chooserows(pvt,1),wkTtlHlp,2,0)),
{dow;pvt;dayTtl;wkTtl}))

使用与实时数据不同的选项卡,并将 liveData 变量中的引用从“源”(此处用作占位符)更改为指向您为表单数据到达的实际选项卡命名的任何内容。我忽略源中的 DateVal/Date/Year/DayOfWeek 列,因为(我假设)它们是根据表单数据旁边的公式计算的。

我不会全部解释,但我们基本上是分别创建表格的不同元素,然后最后将它们堆叠在一起。

© www.soinside.com 2019 - 2024. All rights reserved.