[英]Google Sheets ArrayFormula with Sumifs
Usually don't need help with sheets but I think my brain is imploding from thinking on this too much.通常不需要床单方面的帮助,但我认为我的大脑因考虑太多而崩溃。
Trying to fill an entire column with an array formula that sums values from a separate column based on conditions from two other columns.试图用一个数组公式填充整个列,该公式根据其他两列的条件对单独列的值求和。 If that sounds strange just check out this example sheet .
如果这听起来很奇怪,请查看此示例表。
Invoices have numbers.发票有编号。 Customer payments have "Into" bank accounts and also invoice numbers associated with them so I know which payment corresponds to which invoice.
客户付款具有“汇入”银行帐户以及与之关联的发票编号,因此我知道哪笔付款对应于哪张发票。 Sometimes payments are made in pieces.
有时付款是分批付款的。 I would like to sum all payments for each invoice and on separate accounts.
我想汇总每张发票和单独帐户的所有付款。 I know how to do this using sumifs.
我知道如何使用 sumifs 做到这一点。 The trick I want to pull is doing this with one array formula in the first cell.
我想使用的技巧是在第一个单元格中使用一个数组公式。 Appreciate all help.
感谢所有帮助。
The solution that I ended up using was this:我最终使用的解决方案是:
Credit due to 2n9 from google forums.由于来自谷歌论坛的 2n9 信用。 Here is the link
这是链接
=arrayformula(sumif(B3:B8&C3:C8,F3:F8&"A",A3:A8))
There were some other very good answers there using queries from Jean-Pierre Verhulst:使用 Jean-Pierre Verhulst 的查询还有其他一些非常好的答案:
=query(A2:C8, "select B, sum(A) group by B pivot C")
=query(query(A2:C8, "select B, sum(A) group by B pivot C"), "select Col2, Col3")
=ArrayFormula(query(query(A2:C8, "select B, sum(A) group by B pivot C"), "select Col2, Col3 offset 1",0)+0)
Each of these solutions solves the problem but in a different way.这些解决方案中的每一个都以不同的方式解决了问题。 They have different attributes such as removing headers or choosing only a certain column.
它们具有不同的属性,例如删除标题或仅选择特定列。 Use the link to the google forum for more information.
使用谷歌论坛的链接了解更多信息。
Hope this helps someone.希望这可以帮助某人。
I have added a column to combine the two conditions that need to match in both tables.我添加了一个列来组合两个表中需要匹配的两个条件。
I used an arrayformula to extend the combined conditions, then I used a sumif inside of another arrayformula to do what would have effectively been sumifs within an arrayformula.我使用 arrayformula 来扩展组合条件,然后我在另一个 arrayformula 中使用 sumif 来执行在 arrayformula 中实际上是 sumifs 的操作。
Table 1 (Paint Estimate)表 1(油漆估算)
=ARRAYFORMULA(IFERROR(IF(E2:E<>"",E2:E&"First Coat",0),"E"))
=ARRAYFORMULA(IFERROR(SUMIF(Progress!B2:B,T2:T,Progress!G2:G),0))
Table 2 (Progress)表 2(进度)
=ARRAYFORMULA(A2:A&E2:E)
You can use SUMIFS to return an array, eg in L3您可以使用 SUMIFS 返回一个数组,例如在 L3
=SUMIFS(A3:A8,B3:B8,F3:F8,C3:C8,"A")
=SUMIFS(A3:A8,B3:B8,F3:F8,C3:C8,"A")
Note that where a single criteria is normally expected I have used F3:F8, so the formula returns the required array of 6 values请注意,在通常需要单个条件的情况下,我使用了 F3:F8,因此该公式返回所需的 6 个值数组
Untested as I'm currently on my ipad and it doesn't seem to like google docs....未经测试,因为我目前在我的 ipad 上,它似乎不喜欢谷歌文档....
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.