Nested If Statement using Sum (Need to Optimize)

%3CLINGO-SUB%20id%3D%22lingo-sub-1990893%22%20slang%3D%22en-US%22%3ENested%20If%20Statement%20using%20Sum%20(Need%20to%20Optimize)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1990893%22%20slang%3D%22en-US%22%3E%3CP%3EI%20am%20using%20Sum(IF(%20in%20order%20to%20sum%20data%20based%20on%20Column%20and%20Row%20lookup.%20Except%20every%20time%20I%20paste%20the%20formulas%20into%20the%20sheet%20it%20takes%205-10%20mins%20for%20it%20to%20process.%2010%2C000%20cells%20max.%20What%20can%20I%20use%20that%20would%20provide%20a%20much%20faster%20outcome%3F%20Because%20no%20one%20will%20use%20this%20sheet%20if%20it%20takes%20that%20long%20and%20three%20other%20sheets%20require%20it%20as%20well.%3C%2FP%3E%3CP%3EThe%20formula%20must%20look%20up%20and%20match%20to%20a%20row%20header%20and%20then%20match%20data%20to%20a%20column.%20I'm%20hoping%20I%20get%20an%20answer%20today%20which%20is%20why%20I%20posted%20here%20because%20everyone%20here%20are%20rock%20stars.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1990893%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1990975%22%20slang%3D%22en-US%22%3ERe%3A%20Nested%20If%20Statement%20using%20Sum%20(Need%20to%20Optimize)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1990975%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F612943%22%20target%3D%22_blank%22%3E%40heylookitsme%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EDepends%20on%20you%20Excel%20version%20and%20actual%20data%20structure%2C%20but%20did%20you%20try%20something%20like%20this%3F%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20730px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F240811iDC9334CE4ACD55D4%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2098233%22%20slang%3D%22en-US%22%3ERe%3A%20Nested%20If%20Statement%20using%20Sum%20(Need%20to%20Optimize)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2098233%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3EWhat%20I%20ended%20up%20doing%20was%20using%20VBA%2C%20creating%20a%20separate%20sheet%20in%20the%20workbook%20and%20moving%20over%20the%20columns%20I%20needed%20to%20calculate%20to%20this%20new%20sheet.%20I%20then%20complete%20the%20calculations%20in%20this%20sheet%20and%20copy%20and%20paste%20the%20data%20as%20value%20back%20into%20the%20original%20sheet.%3C%2FP%3E%3CP%3EI%20like%20Excel%20Table%20Format%20for%20all%20of%20the%20flexibility%20it%20gives%20me.%20However%2C%20It%20is%20much%20faster%20to%20calculate%20data%20not%20using%20an%20Excel%20Table.%20I%20have%20found%20that%20Excel%20Tables%20only%20use%2050%25%20of%20your%20PC's%20Processing%20power%20where%20autofilter%20data%20uses%20up%20to%20100%25%20of%20your%20processors.%20From%20my%20understanding%20this%20has%20been%20a%20known%20issue%20with%20Excel%20Tables%20for%20a%20long%2C%20long%20time%20and%20I%20really%20wish%20they%20would%20fix%20it.%20I%20addressed%20this%20by%20up%20voting%20it%20in%20Excel%20Ideas%20Forum.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Contributor

I am using Sum(IF( in order to sum data based on Column and Row lookup. Except every time I paste the formulas into the sheet it takes 5-10 mins for it to process. 10,000 cells max. What can I use that would provide a much faster outcome? Because no one will use this sheet if it takes that long and three other sheets require it as well.

The formula must look up and match to a row header and then match data to a column. I'm hoping I get an answer today which is why I posted here because everyone here are rock stars.

8 Replies

@heylookitsme 

Depends on you Excel version and actual data structure, but did you try something like this?

image.png

@Sergei BaklanWhat I ended up doing was using VBA, creating a separate sheet in the workbook and moving over the columns I needed to calculate to this new sheet. I then complete the calculations in this sheet and copy and paste the data as value back into the original sheet.

I like Excel Table Format for all of the flexibility it gives me. However, It is much faster to calculate data not using an Excel Table. I have found that Excel Tables only use 50% of your PC's Processing power where autofilter data uses up to 100% of your processors. From my understanding this has been a known issue with Excel Tables for a long, long time and I really wish they would fix it. I addressed this by up voting it in Excel Ideas Forum.

@heylookitsme I can't say I reproduce this. Tables do have some perf hit, but it isn't too bad in the test I did (see test workbook attached).

Two sheets: A sheet with data in a table (10,000 rows) and the sumproduct formula

and an identical sheet with the same data, not in a table.

 

I ran VBA code doing this for both worksheets:

  • Calc on auto
    • Run 50 times:
      • Filter the table using greater than 50 on the second column
      • Unfilter the table
  • Calc on manual
    • Run 50 times:
      • Filter the table using greater than 50 on the second column
      • Unfilter the table

 

I get these results:

 

Calc RangeFilter TableFIlter
auto 1.840 2.068
manual 0.584 0.490

 

With calculation ON, filtering the table takes longer than filtering the range

With calculation OFF, filtering the table takes less than filtering the range

 

But the difference isn’t that shocking.

 

If I delete all formulas and rerun the code I get this:

2021-01-27_16-22-52.png

 

Even now, there is a difference between having calc on or off, but now filtering the range is quicker in both situations, by about 20%.

@heylookitsme , and on which Excel you are?

Microsoft 365 Apps for Enterprise
Version 2008 (Build 13127.21064)
Semi-Annual Enterprise Channel

@heylookitsme 

Here results shall be close to @Jan Karel Pieterse  test, other words no dramatical difference in performance between table and range.

@heylookitsme 

 

If it's possible to sort your data, at least by a primary key, then you may be able to use match functions as helpers to narrow the range your sumif(s)/sumproduct function is evaluating. I've used this in the past and, as I recall, made a notable difference.

 

JMB17_0-1611781682833.png

 

@JMB17I failed to mention that my Table has 450 Columns of Data. That may be the issue. I can't reduce those columns either. Seems like issues such as this occur when a table exceeds 250 columns. I also noticed that file size increases significantly when I pass the 250 column mark.