[英]Sum a unique query on multiple pages in Google Sheets
This is a tough one!这是困难的一个!
Sheet I'm working on: https://docs.google.com/spreadsheets/d/1fIBFq4q179k6-5YuhoFZ-3X84tMMkLmIUeV9-KpjN9I/edit?usp=sharing我正在处理的工作表: https://docs.google.com/spreadsheets/d/1fIBFq4q179k6-5YuhoFZ-3X84tMMkLmIUeV9-KpjN9I/edit?usp=sharing
On the 'Report' Tab, in cell C22 and D22 I am trying to figure out how to Total the amount that was paid in the months of November and October.在“报告”选项卡上,在单元格 C22 和 D22 中,我试图弄清楚如何合计 11 月和 10 月支付的金额。 Across all tabs (and to include future tabs as they are added).
跨所有选项卡(并在添加将来的选项卡时包括它们)。
You can see on the individual stock number pages (Example 'PT-1010:' K14.K) that the payments are already broken down by total for the month, How do I search across all pages?您可以在单个股票编号页面(例如“PT-1010:”K14.K)上看到付款已按当月总额细分,如何搜索所有页面? find out if it says 'November-20' and count them all up - and spit out one number?
找出它是否显示“11 月 20 日”并将它们全部计数 - 并吐出一个数字?
My brain hurts lol - any help is very much appreciated!!我的大脑很痛大声笑 - 非常感谢任何帮助!
This may help.这可能会有所帮助。 ( See my sample sheet here )
( 在这里查看我的样本表)
This grabs an array of all of the payments, with a date less than now, using indirect addressing from a list of the stock numbers from the Customers page.这使用来自客户页面的股票编号列表中的间接寻址来获取所有付款的数组,日期少于现在。 I pull this list into a location (U2 in my testing) using this formula:
我使用以下公式将此列表拉到一个位置(我的测试中的 U2):
=query(Customers!A5:A,"where A<>'' order by A",0)
So that is always a current/dynamic list.所以这始终是一个当前/动态列表。
Then the main formula uses indirect addressing to pull the tab names from this list, and collects all of the data.然后主公式使用间接寻址从该列表中提取选项卡名称,并收集所有数据。 I added the filters to reduce the number of rows collected, since you have lots of future dates.
我添加了过滤器以减少收集的行数,因为您有很多未来的日期。
Then I use a query to filter by the desired month, using indirect addressing to the date cells in Report.然后我使用查询来过滤所需的月份,使用间接寻址到报表中的日期单元格。 This allows the exact same formula to be used for both C22 (Nov.) and D22 (Oct.).
这允许对 C22(11 月)和 D22(10 月)使用完全相同的公式。
The main formula, calculating the totals paid in each month, is:计算每个月支付总额的主要公式是:
=query({filter(indirect(U3 &"!B7:E"),indirect(U3 &"!B7:B")<Now());
filter(indirect(U4 &"!B7:E"),indirect(U4 &"!B7:B")<Now());
filter(indirect(U5 &"!B7:E"),indirect(U5 &"!B7:B")<Now());
filter(indirect(U6 &"!B7:E"),indirect(U6 &"!B7:B")<Now());
filter(indirect(U7 &"!B7:E"),indirect(U7 &"!B7:B")<Now());
filter(indirect(U8 &"!B7:E"),indirect(U8 &"!B7:B")<Now());
filter(indirect(U9 &"!B7:E"),indirect(U9 &"!B7:B")<Now());
filter(indirect(U10 &"!B7:E"),indirect(U10 &"!B7:B")<Now());
filter(indirect(U11 &"!B7:E"),indirect(U11 &"!B7:B")<Now());
filter(indirect(U12 &"!B7:E"),indirect(U12 &"!B7:B")<Now());
filter(indirect(U13 &"!B7:E"),indirect(U13 &"!B7:B")<Now());
filter(indirect(U14 &"!B7:E"),indirect(U14 &"!B7:B")<Now());
filter(indirect(U15 &"!B7:E"),indirect(U15 &"!B7:B")<Now());
filter(indirect(U16 &"!B7:E"),indirect(U16 &"!B7:B")<Now());
filter(indirect(U17 &"!B7:E"),indirect(U17 &"!B7:B")<Now());
filter(indirect(U18 &"!B7:E"),indirect(U18 &"!B7:B")<Now());
filter(indirect(U19 &"!B7:E"),indirect(U19 &"!B7:B")<Now()) },
"select sum(Col4) where Col4 >0 and Col1 >= date '"& text(indirect(address(row()-3,column() ,4,1)),"yyyy-mm-dd") &"'
and Col1 < date '"& text(indirect(address(row()-3,column()-1,4,1)),"yyyy-mm-dd") &"' label sum(Col4) '' ",0)
Using just formulae, instead of a script, I can't think of another way to cycle through multiple tabs.仅使用公式而不是脚本,我想不出另一种方法来循环浏览多个选项卡。 You could repeat the FILTER lines in the formula to handle as many customers as you need.
您可以重复公式中的 FILTER 行来处理您需要的尽可能多的客户。 If you are going to have a lot more, then you might need to go to a script.
如果你想要更多,那么你可能需要 go 到一个脚本。 You might need dummy tabs, if you extend the formula now, to handle future customers.
如果您现在扩展公式,您可能需要虚拟标签来处理未来的客户。
And, I think some error checking may be required, to handle possible errors in the indirect addressing to tabs.而且,我认为可能需要进行一些错误检查,以处理间接寻址选项卡中可能出现的错误。 Possibly a test to ensure we aren't pulling a blank value from the list of stock numbers, which equate to the tab names.
可能是一个测试,以确保我们没有从库存编号列表中提取空白值,这等同于选项卡名称。 Or maybe an IFERROR can cover those, one for each FILTER statement.
或者,一个 IFERROR 可以涵盖这些,每个 FILTER 语句都有一个。
Let me know if this helps.让我知道这是否有帮助。
If you remove the date criteria in the last rows, and change the "sum(Col4)" to "Col1, Col4 order by Col1", you get all the data records with payments (column E in each tab, correct?) and can verify the result.如果您删除最后几行中的日期条件,并将“sum(Col4)”更改为“Col1, Col4 order by Col1”,您将获得所有包含付款的数据记录(每个选项卡中的 E 列,对吗?)并且可以验证结果。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.