简体   繁体   English

处理日期时,Google 表格 ARRAYFORMULA + SUMIFS

[英]Google sheets ARRAYFORMULA + SUMIFS when working with dates

im trying to figure out how can i use an arrayformula + SUMIFS when working with dates我试图弄清楚在处理日期时如何使用 arrayformula + SUMIFS

Here is a demo sheet这是一个演示表

https://docs.google.com/spreadsheets/d/1ttoA9EfMdYJHolcRVrLfpDA2GqYtt19gJruDogzGSf8/edit?usp=sharing https://docs.google.com/spreadsheets/d/1ttoA9EfMdYJHolcRVrLfpDA2GqYtt19gJruDogzGSf8/edit?usp=sharing

what i need :我需要的 :

in column OI need the balance overdue by client when the date of the payment < today() I need an arrayformula since is a very big data set在 OI 列中,当付款日期 < today() 时,客户需要逾期未付的余额 我需要一个数组公式,因为它是一个非常大的数据集

trying to use arrayformula + sumifs does not expand尝试使用 arrayformula + sumifs 不会扩展

trying to use arrayformula + sumif and using the & symbol is not working maybe because I need only when is < today ()尝试使用 arrayformula + sumif 并使用 & 符号不起作用可能是因为我只需要什么时候是 < 今天 ()

={"overdue";ARRAYFORMULA(IF(LEN(A2:A), (SUMIF(R:R&A:A,Q:Q&"<"&TODAY(),V:V))-M2:M ,))}

im looking for an alternative to this, any help will be very much apreciatted我正在寻找替代方案,任何帮助都会非常感谢

Thank you !谢谢 !

I need an arrayformula since is a very big data set我需要一个数组公式,因为它是一个非常大的数据集

The mmult() function will error out when the dataset exceeds 3162 rows.当数据集超过 3162 行时mmult()函数将出错。 To avoid that, use vlookup() and query() , like this:为避免这种情况,请使用vlookup()query() ,如下所示:

=arrayformula( 
  { 
    "Overdue";
    iferror( 
      vlookup( 
        A2:A, 
        query( 
          Q2:V, 
          "select R, sum(V) 
           where Q <= date" & text(today(), " 'yyyy-MM-dd' ") & "
           group by R", 
          0 
        ), 
        2, false 
      ) 
      - M2:M 
    ) 
  } 
)

See the doubleunary sheet.双元表。

I've added a new sheet ("Erik Help") to your sample spreadsheet.我在您的示例电子表格中添加了一个新工作表(“Erik 帮助”)。 The following array formula is in O2:以下数组公式在 O2 中:

=ArrayFormula({"Overdue"; IF(A2:A="",, MMULT( TRANSPOSE(U2:U) * (TRANSPOSE(Q2:Q)=A2:A) * (TRANSPOSE(P2:P)<=TODAY() ),SEQUENCE( ROWS(U2:U), 1, 1, 0)) - M2:M)})

A virtual array is formed between the curly brackets { }.大括号{}之间形成一个虚拟数组。

The header is set first (which can be changed within the formula as you like).首先设置标题(可以根据需要在公式中更改)。

If any cell in A2:A is null, then the corresponding cell in O2:O will also be null.如果 A2:A 中的任何单元格为空,则 O2:O 中的相应单元格也将为空。

MMULT performs M atric MULT iplication. MMULT执行M atric MULT iplication。 Here, I've used it to multiply a TRANSPOSE d version of the amounts in U2:U by two TRANSPOSE d conditional statements (each of which will result to a 1 of TRUE or a 0 if FALSE).在这里,我用它将 U2:U 中数量的TRANSPOSE d 版本乘以两个TRANSPOSE d 条件语句(每个语句都将导致 TRUE 的 1 或 FALSE 的 0)。 If both statements are TRUE, then the value from U2:U will remain (ie, X * 1 * 1);如果两个语句都为 TRUE,则 U2:U 中的值将保持不变(即 X * 1 * 1); but if either statement is FALSE, then the result for that row of U2:U will be 0 (eg, X * 0 * 1 -or- X * 1 * 0 -or- X * 0 * 0).但如果任一语句为 FALSE,则 U2:U 的该行的结果将为 0(例如,X * 0 * 1 -或- X * 1 * 0 -或- X * 0 * 0)。

The conditional statements check 1.) to see if the client name is the same as the current row;条件语句检查 1.) 以查看客户端名称是否与当前行相同; and 2.) to see if the date is less than or equal to TODAY().和 2.) 查看日期是否小于或等于 TODAY()。

It is important that these three readings be TRANSPOSE d, in order to form a 2D virtual grid.重要的是这三个读数是TRANSPOSE d,以便形成一个 2D 虚拟网格。

The remaining values after the above process will be in virtual horizontal rows parallel to each actual row.上述过程后的剩余值将在与每个实际行平行的虚拟水平行中。 These form the first matrix.这些构成了第一个矩阵。

The second matrix is formed with SEQUENCE and is simply a stack of the number 1 as tall as the number of rows from A2:A in the sheet.第二个矩阵由SEQUENCE形成,它只是一个数字 1 的堆栈,其高度与工作表中 A2:A 的行数一样高。

Since anything times 1 is the original number, all 0 or value results from the first matrix are returned and then added (which is the function of MMULT ).由于任何乘以 1 的值都是原始数字,因此返回第一个矩阵的所有 0 或值结果,然后相加(这是MMULT的函数)。

From this, the value in M2:M can be subtracted.从中可以减去 M2:M 中的值。

I think you just have to subtract clients who are earlier alphabetically and client/dates which are later alphabetically from the total, still using sumif:我认为您只需要从总数中减去按字母顺序排列较早的客户和按字母顺序排列较晚的客户/日期,仍然使用 sumif:

=ArrayFormula(if(A2:A="",,sum(V2:V)-sumif(R2:R,"<"&A2:A,V2:V)-sumif(R2:R&Q2:Q,">"&A2:A&today(),V2:V)-M2:M))

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM