按月份和年份求和:在Google表格中查询以及如何忽略空白单元格?

huangapple go评论88阅读模式
英文:

Sum by Month & Year: Query in Google Sheets and how to ignore blank cells?

问题

Sum by Month & Year: 在Google Sheets中查询

S1中的日期格式为 mm/dd/yy
尝试对 ‘S1’!F 中的值求和

我找到了这篇帖子 ,其中contributorpw的方法非常合适。但是,我不知道如何排除col A中的空单元格。

我知道使用QUERY可以这样做:“…where A is not null”,但是使用以下代码出现了错误消息:

=QUERY(ARRAYFORMULA({TEXT('S1'!A:A,"YYYY-MM"),'S1'!F:F}),"select Col1,sum(Col2) where A is not null group by Col1")

而且这仍然返回了‘S1’!A中的空单元格的值:

=QUERY(ARRAYFORMULA({TEXT('S1'!A:A,"YYYY-MM"),'S1'!F:F}),"select Col1,sum(Col2) where Col1 is not null group by Col1")
英文:

Sum by Month & Year: Query in Google Sheets

The date format in S1 is mm/dd/yy
Attempting to sum the values in ‘S1’!F

I found this post and contributorpw’s method was spot on. However, I don’t know how to exclude blank cells in col A.

I know with QUERY: “…where A is not null” but got error message with:

=QUERY(ARRAYFORMULA({TEXT('S1'!A:A,"YYYY-MM"),'S1'!F:F}),"select Col1,sum(Col2) where A is not null group by Col1")

And this still returned values for blank cells in ‘S1’!A:

=QUERY(ARRAYFORMULA({TEXT('S1'!A:A,"YYYY-MM"),'S1'!F:F}),"select Col1,sum(Col2) where Col1 is not null group by Col1")

答案1

得分: 1

以下是翻译好的部分:

你可以尝试:

=query({index(if(len('S1'!A2:A),eomonth('S1'!A2:A,),)),'S1'!F2:F},"select Col1,sum(Col2) Where Col1 is not null group by Col1 label sum(Col2) '' format Col1 'mmm-YY'")

英文:

You may try:

=query({index(if(len('S1'!A2:A),eomonth('S1'!A2:A,),)),'S1'!F2:F},"select Col1,sum(Col2) Where Col1 is not null group by Col1 label sum(Col2) '' format Col1 'mmm-YY'")

按月份和年份求和:在Google表格中查询以及如何忽略空白单元格?

huangapple
  • 本文由 发表于 2023年5月29日 23:23:44
  • 转载请务必保留本文链接:https://go.coder-hub.com/76358522.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定