我已使用QUERY
从时间表中提取数据(请参见代码)。我想将每行和每列的总计相加,即用总和公式替换“ 2”,“ 3”,“ 4”...。并以某种方式为每行总计添加一行代码。我已将链接添加到电子表格的副本...工作表小时摘要。
https://docs.google.com/spreadsheets/d/1czL8ttM-0Z7wPInkzOTQA8w0B24TiqC9OP-2rFjD2Dc/edit?usp=sharing
我尝试从源数据集中求和,并添加一个带有QUERY
子句的WHERE
。除非我不清楚在这种情况下要过滤什么。我对此并不陌生,因此尚未完全掌握所有语法。我似乎无法以某种方式弄清楚这个问题的最后一站。感谢您的帮助。
={query(query(formData, "select E, C, sum(H) where C != '' group by E, C", 1), "select Col1, Sum(Col3) group by Col1 Pivot Col2 label Col1'Month'");{"Total","2","3","4","5","6","7","8","9","10","11","12"}}
答案 0 :(得分:1)
={{QUERY(QUERY(formData,
"select E, C, sum(H)
where C is not null
group by E, C", 1),
"select Col1, sum(Col3)
group by Col1
pivot Col2
label Col1'Month'");
{QUERY(QUERY(QUERY(QUERY(formData,
"select E, C, sum(H)
where C is not null
group by E, C", 1),
"select Col1, sum(Col3)
group by Col1
pivot Col2 label Col1''"),
"select 'x',Col2,Col3,Col4,Col5,Col6,Col7,Col8,Col9,Col10,Col11,Col12"),
"select 'Total',sum(Col2),sum(Col3),sum(Col4),sum(Col5),sum(Col6),sum(Col7),sum(Col8),sum(Col9),sum(Col10),sum(Col11),sum(Col12)
group by Col1
label 'Total''',sum(Col2)'',sum(Col3)'',sum(Col4)'',sum(Col5)'',sum(Col6)'',sum(Col7)'',sum(Col8)'',sum(Col9)'',sum(Col10)'',sum(Col11)'',sum(Col12)''")}},
ARRAYFORMULA(QUERY(VALUE({QUERY(QUERY(formData,
"select E, C, sum(H)
where C is not null
group by E, C", 1),
"select Col1, sum(Col3)
group by Col1
pivot Col2
label Col1'Month'");
{QUERY(QUERY(QUERY(QUERY(formData,
"select E, C, sum(H)
where C is not null
group by E, C", 1),
"select Col1, sum(Col3)
group by Col1
pivot Col2 label Col1''"),
"select 'x',Col2,Col3,Col4,Col5,Col6,Col7,Col8,Col9,Col10,Col11,Col12"),
"select 'Total',sum(Col2),sum(Col3),sum(Col4),sum(Col5),sum(Col6),sum(Col7),sum(Col8),sum(Col9),sum(Col10),sum(Col11),sum(Col12)
group by Col1
label 'Total''',sum(Col2)'',sum(Col3)'',sum(Col4)'',sum(Col5)'',sum(Col6)'',sum(Col7)'',sum(Col8)'',sum(Col9)'',sum(Col10)'',sum(Col11)'',sum(Col12)''")}}),
"select Col2+Col3+Col4+Col5+Col6+Col7+Col8+Col9+Col10+Col11+Col12
label Col2+Col3+Col4+Col5+Col6+Col7+Col8+Col9+Col10+Col11+Col12'Total'"))}
答案 1 :(得分:0)
={QUERY(QUERY(formData,
"select E, C, sum(H)
where C != ''
group by E, C", 1),
"select Col1, sum(Col3)
group by Col1
pivot Col2
label Col1'Month'");
{QUERY(QUERY(QUERY(QUERY(formData,
"select E, C, sum(H)
where C != ''
group by E, C", 1),
"select Col1, sum(Col3)
group by Col1
pivot Col2 label Col1''"),
"select 'x',Col2,Col3,Col4,Col5,Col6,Col7,Col8,Col9,Col10,Col11,Col12"),
"select 'Total',sum(Col2),sum(Col3),sum(Col4),sum(Col5),sum(Col6),sum(Col7),sum(Col8),sum(Col9),sum(Col10),sum(Col11),sum(Col12)
group by Col1
label 'Total''',sum(Col2)'',sum(Col3)'',sum(Col4)'',sum(Col5)'',sum(Col6)'',sum(Col7)'',sum(Col8)'',sum(Col9)'',sum(Col10)'',sum(Col11)'',sum(Col12)''")}}