最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

excel - SUMIF with row and column criteria over large dataset - Stack Overflow

programmeradmin2浏览0评论
0 A B C D E F G
1 product 2024-01 2024-02 2024-03 2024-04 product_c
2 product_a 100 200 500 910 2024-03
3 product_a 350 890 260 750
4 product_b 240 300 710 810 1602
5 product_c 900 800 620 370
6 product_c 300 750 835 255
7 product_c 290 340 147 647
0 A B C D E F G
1 product 2024-01 2024-02 2024-03 2024-04 product_c
2 product_a 100 200 500 910 2024-03
3 product_a 350 890 260 750
4 product_b 240 300 710 810 1602
5 product_c 900 800 620 370
6 product_c 300 750 835 255
7 product_c 290 340 147 647

In Cell G4 I make a SUMIF based on the column criteria in Cell G1 and the row criteria in Cell G2 using this formula:

=SUMIF($A$1:$A$7,$G$1,INDEX($A$1:$E$1,MATCH($G$2,$A$1:$E$1,0)))

All this works fine.


However, in my original file I have the issue now that the dataset is much larger compared to this example.

In the example the columns only go until 2024-04.

In my original file I have
(a) much more years on a monthly basis and
(b) much more products and therefore much more rows.

This leads to the situation that the loading time when using the formula significantly increases.

Do you know if there is any alternative approach/formula which has the same functionality but does not effect the loading times as much?

Share Improve this question asked Apr 2 at 7:44 MichiMichi 5,5658 gold badges57 silver badges119 bronze badges 2
  • 1 1) I don't understand how your formula even outputs the correct result, but it does!; 2) You could try something like this: =SUM(($B$2:$E$7)*($B$1:$E$1=$G$2)*($A$2:$A$7=$G$1)), but I can't tell if it's faster or not. How big is your actual data set that you're getting slow responses? – Excellor Commented Apr 2 at 7:56
  • 2 What do you mean by loading time? The sheet opening or the execution? – Black cat Commented Apr 2 at 8:48
Add a comment  | 

1 Answer 1

Reset to default 0

=SUMPRODUCT((A2:A7=G1)\*(B1:E1=G2)\*B2:E7)

  1. SUMPRODUCT processes arrays efficiently without needing multiple lookup functions.

  2. Works well if the dataset is structured properly.

发布评论

评论列表(0)

  1. 暂无评论