Excel:优化一堆非常重的 SUMIFS

发布于 2024-12-22 05:01:18 字数 750 浏览 2 评论 0原文

我想要根据某些条件对一些数据进行求和

示例数据:

  A    B   C   D
  Id   Id2 Id3 Val
  1    1   8   6
  1    2   7   7
  1    3   3   8
  1    4   6   4
  1    4   78  7
  1    1   2   9
  1    3   1   4
  1    4   3   6
  1    1   5   8
  1    4   7   2

现在我希望根据每个 的特定条件(例如 Id2=4 和 Id3=2)对每个 Id 求和 Val Id 有 100 个值,但我想避免为每个 Id 重新运行 sumif,因为表很重。

到目前为止我一直在做的是

= SUMIFS(D:D, A:A, "=1", B:B, "=4", C:C, "=2")
= SUMIFS(D:D, A:A, "=2", B:B, "=4", C:C, "=2")
= SUMIFS(D:D, A:A, "=3", B:B, "=4", C:C, "=2")
= SUMIFS(D:D, A:A, "=4", B:B, "=4", C:C, "=2") ... 

(如果我正确记住了 sumifs 的语法)

是否有一种更快的方法可以避免为每个 Id 重新运行 sumifs ?

I have some data that I want summed matching certain criteria

Example data:

  A    B   C   D
  Id   Id2 Id3 Val
  1    1   8   6
  1    2   7   7
  1    3   3   8
  1    4   6   4
  1    4   78  7
  1    1   2   9
  1    3   1   4
  1    4   3   6
  1    1   5   8
  1    4   7   2

Now I want the Val summed for every Id, based on certain criteria (e.g. Id2=4 and Id3=2) for every Id which has 100 values, but I want to avoid rerunning the sumifs for every Id since the table is heavy.

What I have been doing so far is to

= SUMIFS(D:D, A:A, "=1", B:B, "=4", C:C, "=2")
= SUMIFS(D:D, A:A, "=2", B:B, "=4", C:C, "=2")
= SUMIFS(D:D, A:A, "=3", B:B, "=4", C:C, "=2")
= SUMIFS(D:D, A:A, "=4", B:B, "=4", C:C, "=2") ... 

(if I remember the syntax of sumifs correctly)

Is there a faster way that avoids rerunning the sumifs for each Id ?

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

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

发布评论

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

评论(2

无法言说的痛 2024-12-29 05:01:18

如果您想以这种方式计算大量 SUM,最好使用 数据透视表

您也可以尝试 DSUM,但我怀疑它会比 SUMIF 更快。

If you want to figure lots of SUMs in this way, it's best done with a pivot table.

You may also try DSUM, but I doubt it's going to be any faster than SUMIF.

荭秂 2024-12-29 05:01:18

您还可以执行 数组公式 这也应该快如闪电。

因此,请选择您想要的结果范围,然后按 F2 输入您想要第一个公式的位置。然后输入以下数组公式:

= SUMIFS(D:D, A:A, "="&{1;2;3;4}, B:B, "=4", C:C, "=2")

或者

= SUMIFS(D:D, A:A, "="&G1:G4, B:B, "=4", C:C, "=2")

其中 G1G4 包含您要迭代的值。

这将使它只获取数据一次而不是多次,并且一次返回所有值而不是多次。

如果您想从左到右迭代,请在数组中使用逗号而不是分号

当您输入数组公式时,请按以下方式输入:

Ctrl+Shift+Enter

You could also do an array formula which should also be lightning fast.

So select the range that you want your results, then push F2 to enter where you want your first formula. Then put in the below array formula:

= SUMIFS(D:D, A:A, "="&{1;2;3;4}, B:B, "=4", C:C, "=2")

or

= SUMIFS(D:D, A:A, "="&G1:G4, B:B, "=4", C:C, "=2")

where G1 to G4 have your values you want to iterate over.

This will make it so it only grabs the data only once rather than multiple times and will return all the values one time rather than multiple times.

If you want to iterate from left to right use a comma instead of a semicolon in your array.

When you enter an array formula enter it this way:

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