如何在Google表中与Arrayformula一起使用SUMIF

发布于 2025-02-06 05:39:57 字数 327 浏览 1 评论 0原文

从Google表格中,我们将获得NOS车辆的输入。在一段时间内,其中一些车辆可能相同。在此期间,我们可能已经注意到这辆车辆犯的交通犯罪。我们是否可以编写代码/功能来实现所述车辆侵犯的罪行的总和?

Col A:时间戳 Col B:车辆编号(从Google表格获得的数据) Col C:输入数(通过基于Col B的Countif相似的Vookup/Query〜获得) Col D:违规数量(1如果是,空单元表示否) Col E:总违规数量〜希望总计基于Col B的总数。

因此,每次Google表格提交,Google Sheet将检查该车辆在Col E中积累并自动化的犯罪总数是多少。

谢谢您的指导。

From google forms, we will get inputs of vehicle nos. over a period of time, and some of these vehicle may be the same. Over this period, we may have noted the traffic offence made by this vehicle. Is there a code/function we can write to sum of the offences the said vehicle had violated?

Col A:Timestamp
Col B:Vehicle No. (Data obtained from google form)
Col C:Entry Count (obtained via VLookup/Query ~ similar to countif based on Col B)
Col D:Violation Count (1 if yes, empty cell means no)
Col E:Total Violation Count ~ hoping to sum the total based on Col B.

As such, with each new google form submission, the google sheet will check what is the total number of offences the said vehicle had accumulated and automate in Col E.

Thank you for your guidance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

孤芳又自赏 2025-02-13 05:39:57

如果您需要在车辆上每行的违规总数相同,则是:

=ARRAYFORMULA(
  IF(
    ROW(D:D) = 1,
      "Total Violation Count",
      IFNA(VLOOKUP(
        D:D,
        QUERY(
          D:E,
          "SELECT D, COUNT(D)
           WHERE E IS NOT NULL
           GROUP BY D"
        ),
        2,
      ))
  )
)

“在此处输入图像说明”

如果您需要违规数量的运行总和:

=ARRAYFORMULA(
  IFS(
    ROW(D:D) = 1,
      "Total Violation Count",
    A:A = "",,
    True,
      IFNA(VLOOKUP(
        MATCH(D:D, UNIQUE(FILTER(D2:D, D2:D <> "")),) * 10^INT(LOG10(ROWS(D2:D)) + 1) + ROW(D:D),
        SORT(
          {
            SEQUENCE(COUNTUNIQUE(D2:D)) * 10^INT(LOG10(ROWS(D2:D)) + 1),
            IF(SEQUENCE(COUNTUNIQUE(D2:D)), 0);
            FILTER(MATCH(D2:D, UNIQUE(FILTER(D2:D, D2:D <> "")),) * 10^INT(LOG10(ROWS(D2:D)) + 1) + ROW(D2:D), E2:E <> ""),
            MMULT(
                (FILTER(D2:D, E2:E <> "") = TRANSPOSE(FILTER(D2:D, E2:E <> "")))
              * (SEQUENCE(COUNTA(E2:E)) >= SEQUENCE(1, COUNTA(E2:E))),
              SEQUENCE(COUNTA(E2:E), 1, 1,)
            )
          }
        ),
        2
      ))
  )
)

请注意,第二解决方案具有限制:n^2&lt; 10 000 000,其中n是违规的记录数。那就是Google的表格对也应用于中间计算的单元格总数的限制。

f:f不使用。

If you need to have the same total amount of violations on every row for the vehicle then it would be:

=ARRAYFORMULA(
  IF(
    ROW(D:D) = 1,
      "Total Violation Count",
      IFNA(VLOOKUP(
        D:D,
        QUERY(
          D:E,
          "SELECT D, COUNT(D)
           WHERE E IS NOT NULL
           GROUP BY D"
        ),
        2,
      ))
  )
)

enter image description here

If you need a running sum for the number of violations:

=ARRAYFORMULA(
  IFS(
    ROW(D:D) = 1,
      "Total Violation Count",
    A:A = "",,
    True,
      IFNA(VLOOKUP(
        MATCH(D:D, UNIQUE(FILTER(D2:D, D2:D <> "")),) * 10^INT(LOG10(ROWS(D2:D)) + 1) + ROW(D:D),
        SORT(
          {
            SEQUENCE(COUNTUNIQUE(D2:D)) * 10^INT(LOG10(ROWS(D2:D)) + 1),
            IF(SEQUENCE(COUNTUNIQUE(D2:D)), 0);
            FILTER(MATCH(D2:D, UNIQUE(FILTER(D2:D, D2:D <> "")),) * 10^INT(LOG10(ROWS(D2:D)) + 1) + ROW(D2:D), E2:E <> ""),
            MMULT(
                (FILTER(D2:D, E2:E <> "") = TRANSPOSE(FILTER(D2:D, E2:E <> "")))
              * (SEQUENCE(COUNTA(E2:E)) >= SEQUENCE(1, COUNTA(E2:E))),
              SEQUENCE(COUNTA(E2:E), 1, 1,)
            )
          }
        ),
        2
      ))
  )
)

enter image description here

Be aware that the 2nd solution has a restriction: n^2 < 10 000 000, where n is the number of records with violations. That is Google Sheets restriction on the total number of cells which is also applied to intermediary calculations.

Column F:F is not used.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文