简体   繁体   English

需要替代 sumifs()/sum(filter())/sumproduct() 以提高性能

[英]Need an alternative to sumifs()/sum(filter())/sumproduct() to increase performance

I have a sheet with several columns.我有一张包含几列的表格。 The rows could go up to the 10s of thousands.这些行可以是 go 到几千个。 Some of the rows are subtotals from the rows below.一些行是下面各行的小计。 I have an automated index that works like below:我有一个自动索引,其工作方式如下:

i
i.i
i.i.i
i.i.j
j
j.i
j.j

i is a subtotal of all ix items, while ii is a subtotal of all iix items and so on. i 是所有 ix 项目的小计,而 ii 是所有 iix 项目的小计,依此类推。

The lowerest indexes are always items, which have their own value.最低的索引总是项目,它们有自己的价值。

Problem is, as the sheet is filled and rows are added, it goes slower to the point of becoming unusable.问题是,当工作表被填满并添加行时,它会变慢到无法使用的程度。

link to the desensitized sheet *open in excel, there are named formulas that won't open on google sheets. 链接到脱敏表*在excel打开,有命名公式在google表上打不开。

What consumes processing power is the subtotals.消耗处理能力的是小计。 So far, I have used both: sumifs(), sum(filter()), sumproduct(), sum({array}*{array}), to automatically calculate de subtotals, and the performance is bad on all options.到目前为止,我已经使用了两个:sumifs()、sum(filter())、sumproduct()、sum({array}*{array}),来自动计算去小计,并且所有选项的性能都很差。

I realize that using a regular subtotal() would cut processing consumption, but, in the other hand, when new rows are added in the middle of the sheet, it requires a lot of adjustments to fix the ranges that need to be summed.我意识到使用常规 subtotal() 会减少处理消耗,但另一方面,当在工作表中间添加新行时,需要进行大量调整才能确定需要求和的范围。 Oftenly, my team make some mistake into adjusting the ranges, resulting in wrong subtotals and having a hard time finding it later, consuming a lot of worktime经常,我的团队在调整范围时犯了一些错误,导致错误的小计并且以后很难找到它,消耗了大量的工作时间

Pivot table is not an option, nor the group subtotals, since I need to follow the structure and formatting of the original sheet. Pivot 表不是一个选项,也不是组小计,因为我需要遵循原始表的结构和格式。

Do you guys have any idea on how to do this in a better way?你们知道如何以更好的方式做到这一点吗?

You don't need alternative functions;您不需要替代功能; you simply need to reduce the number of redundant calculations: looking at row 7, the filters in cells O7:R7 are all filtering on the same criteria (which are calculated, afresh, for each filter), so instead of 4 separate (but related, since they all use the same criteria) filters, you could simply write the formula below您只需要减少冗余计算的数量:查看第 7 行,单元格O7:R7中的过滤器根据相同的标准进行过滤(针对每个过滤器重新计算),因此而不是 4 个单独的(但相关的) , 因为它们都使用相同的标准) 过滤器, 你可以简单地写下下面的公式

=LET(net,FILTER(O$2:R$465,(LEFT($I$2:$I$465,LEN($I7)+1)=$I7&".")*($J$2:$J$465<>0)*ISNUMBER(VALUE(RIGHT($I$2:$I$465,1))),0),MMULT(SEQUENCE(1,ROWS(net),1,0),net))

(ie apply a single filter, once , to the 4-column range, and generate a sum for each column) (即对 4 列范围应用一次过滤器,为每列生成一个总和)

in cell O7 , and see that it generates the same totals在单元格O7中,看到它生成了相同的总计

similarly (still on row 7), all of the filters in cells X7:GI7 are also using the same criteria (ie the same criteria being calculated 168 times(,)), such that you could write the formula below类似地(仍然在第 7 行),单元格X7:GI7中的所有过滤器也使用相同的标准(即相同的标准被计算 168 次(,)),这样你可以写下面的公式

=LET(net,N(FILTER(X$2:GI$465,(LEFT($I$2:$I$465,LEN($I7)+1)=$I7&".")*($J$2:$J$465<>0),0)),MMULT(SEQUENCE(1,ROWS(net),1,0),net))

(again, a single filter, once , of a multi-column range, calculating a sum for each column) (再次,多列范围的单个过滤器,一次,计算每列的总和)

in cell X7 and eliminate the redundant calculations from X7:GI7在单元格X7中并消除X7:GI7中的冗余计算

Making these updates will result in 170 fewer uses of the FILTER() function, per sub-total row (together with no-longer duplicated criteria calculations) so I anticipate that this will improve performance to some extent.进行这些更新将减少 170 次FILTER() function 的使用,每个小计行(连同不再重复的标准计算),因此我预计这将在一定程度上提高性能。

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

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