+ Reply to Thread
Results 1 to 26 of 26

SUMIFS formula to replace SUMPRODUCT because of ressource issue

  1. #1
    Registered User
    Join Date
    01-13-2016
    Location
    Paris
    MS-Off Ver
    Office 2016
    Posts
    12

    SUMIFS formula to replace SUMPRODUCT because of ressource issue

    Hi to all,

    I have a large Excel file with a lof of SUMPRODUCT formulas which seems to lead to a lot of error messages about a lack of resources ("Excel cannot complete this task with available resources...").
    I have read that SUMIFS was less memory-intensive than SUMPRODUCT.

    Basically, I am trying to compute the sum of the product of 2 rows but accounting for #N/A (which can be anywhere on those 2 rows). The current formula is :

    SUMPRODUCT(IF(ISNA($AG$4:$BB$4);0;$AG$4:$BB$4)*IF(ISNA(AG307:BB307);0;(AG307:BB307)))

    Is there a way to this more efficiently with SUMIFS ? I have failed to found a way yet.

    thanks a lot !

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: SUMIFS formula to replace SUMPRODUCT because of ressource issue

    The simplest way BY FAR would be to remove the #N/A errors in the first place.... =IFERROR(formula;0)

    Then a straightforward SUMPRODUCT will work fine.
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  3. #3
    Registered User
    Join Date
    01-13-2016
    Location
    Paris
    MS-Off Ver
    Office 2016
    Posts
    12

    Re: SUMIFS formula to replace SUMPRODUCT because of ressource issue

    Yeah, I did tried that a few months ago, but when the cell was empty, it led to other issues in my data table but I can't remember which ones...

    Moreover...assuming it works, will it really make my file less memory-intensive ?

    EDIT : i sort of remember...the things is cannot input zero as an error as it is an admissible value in my data table (basically, I have growth rates of macro variables in different countries on which I make calculations). Hence I tried "" to have an empty cell, but I think it led to some mistakes when I was trying to do my product...
    Last edited by lillumultipass; 12-11-2017 at 12:49 PM.

  4. #4
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: SUMIFS formula to replace SUMPRODUCT because of ressource issue

    Your formula is only looking at 22 columns. If it was looking at 220,000... then maybe. Your performance issue lies elsewhere, methinks.

  5. #5
    Registered User
    Join Date
    01-13-2016
    Location
    Paris
    MS-Off Ver
    Office 2016
    Posts
    12

    Re: SUMIFS formula to replace SUMPRODUCT because of ressource issue

    Yeah, but I have about 200 lines of this formula times 6 columns in a single worksheet and about 25 worksheets with the same structure...
    Don't you think this could be it ?

    I have to admit that I have using Excdel for quite some time, and I had never encountered this issue before...

    Another solution for me would be to "freeze" some of my calculations (these are time series so the results from many years ago is not supposed to change) so as to limit the number of occurences of this formula...

  6. #6
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: SUMIFS formula to replace SUMPRODUCT because of ressource issue

    Thats beginning to get big....

  7. #7
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: SUMIFS formula to replace SUMPRODUCT because of ressource issue

    Yeah, I did tried that a few months ago, but when the cell was empty, it led to other issues in my data table but I can't remember which ones...
    Don't make the formulas return 'blank' (I presume you mean "")
    Instead, make them return 0

  8. #8
    Registered User
    Join Date
    01-13-2016
    Location
    Paris
    MS-Off Ver
    Office 2016
    Posts
    12

    Re: SUMIFS formula to replace SUMPRODUCT because of ressource issue

    No,no, I understand...but this is just not possible with my dataset (I am looking at growth rates or diffusion indices) because 0 is an admissible value that could happen by chance so I don't want my formula to generate a "false" zero

  9. #9
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: SUMIFS formula to replace SUMPRODUCT because of ressource issue

    If by blank, you're talking about "", then standard sumproduct will ignore those.

    Based on your original formula, try this after adjusting the formulas in the ranges to return "" instead of #N/A

    SUMPRODUCT($AG$4:$BB$4;AG307:BB307)

  10. #10
    Registered User
    Join Date
    01-13-2016
    Location
    Paris
    MS-Off Ver
    Office 2016
    Posts
    12

    Re: SUMIFS formula to replace SUMPRODUCT because of ressource issue

    I have already tried that and I had other issues (not with the formula in question but with another formula that I used to count data). But I can try anew...
    the thing is : I will still have 200 lines * 6 * 26 SUMPRODUCT formulas in my workbook. Won't it still be resource-heavy ?

  11. #11
    Forum Expert
    Join Date
    10-02-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    1,222

    Re: SUMIFS formula to replace SUMPRODUCT because of ressource issue

    "Excel cannot complete this task with available resources..."

    This very rarely if ever is attributed to formulas. Its usually a matter of excess content in the file and/or how a user tries to do something (ex: copy/paste whole columns/rows/sheets instead of data range).

    EDIT: forgot to mention. Formulas generally will just increase calc time, not give an error. In the status bar it should display something like % calculating on x threads or something to that effect. If you have a complex calculation tree this can take a while, but ive never seen formulas alone give the out of resources error

    SUMPRODUCT is not as efficient as IFS functions (SUMIFS, COUNTIFS, AVERAGEIFS) but it is more flexible and still faster than SUM(IF array formulas.

    This link from MS details array formulas and lookups. https://msdn.microsoft.com/en-us/vba...rraySumProduct

    Can you post a sanitized sample file?

    If not try the following:

    Open a VBA window with that file open (alt+f11). At the bottom you should have a pane titled "immediate window", if not Ctrl+G. In the immediate window type the following (hit enter after typing in each bullet point line without the bullet):
    • ?Activeworkbook.names.count
    • ?Activeworkbook.styles.count

    This will give you a count of the styles and named ranges in the file. There are 47 styles by default. You may have a ton of either.

    Also, on each sheet the used range should end at the bottom of scrolling down, end of scrolling right. In other words when you scroll on a sheet you should NOT zip past your information seeing blank cells. A good way to test used range on each sheet is to select cell A1 then use the shortcut ctrl+shift+end. This selects what excel thinks is the used range on a sheet. It should end at the intersection of the last column and last row you actually have content in. If not, you have excess content.
    Last edited by Zer0Cool; 12-11-2017 at 02:37 PM.
    Ways to get help: Post clear questions, explain your overall goal, supply as much background as possible, respond to questions asked of you by those trying to help and post sample(s) files.

    "I am here to help, not do it for people" -Me

  12. #12
    Registered User
    Join Date
    01-13-2016
    Location
    Paris
    MS-Off Ver
    Office 2016
    Posts
    12

    Re: SUMIFS formula to replace SUMPRODUCT because of ressource issue

    Thanks for your help.

    Here is the file with only 2 sheets.
    If you look at sheet "IP", the sumproduct formulas start column "BI".

    thanks
    Attached Files Attached Files

  13. #13
    Forum Expert
    Join Date
    10-02-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    1,222

    Re: SUMIFS formula to replace SUMPRODUCT because of ressource issue

    Just a glance and I can tell you have excess cells on at least some sheets. On IP you go way past rows with data and have a fill going in a full column. Clear out the excess on your sheets and I wont be surprised if you have fewer or no errors (again depends on if people are doing something that triggers a problem).

    EDIT: other sheet goes to column WXA, just a tad past your data range

  14. #14
    Forum Expert
    Join Date
    10-02-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    1,222

    Re: SUMIFS formula to replace SUMPRODUCT because of ressource issue

    Couple things that are likely much slower than SUMPRODUCT:

    On IP sheet:

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    you have a bunch of lookup formulas referencing entire columns. look for an alternative to lookup and reference only your data range

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    this could likely be a SUMPRODUCT, maybe a combination of SUMIFS and something. Array entering like this is slow (SUM(IF array or variations of it). You have a bunch of these too. You have variations of SUM(IF arrays throughout the file, you should consider updating them if possible to something like SUMPORODUCT or a combination of IFS functions (SUMIFS, COUNTIFS, AVERAGEIFS).

    Your sample has over 2500 array entered formulas. When possible, using array like formulas like *IFS and SUMPRODUCT will be much faster.

    EDIT: in your sample file your largest component sizes are:
    • The 2 sheet xml files
    • your calc chain xml

    Clearing out excess may reduce the sheet sizes, it likely one or more are significantly larger than they should be due to excess content. Once you alter your formulas as mentioned above I would recommend rebuilding your calc chain (ctrl+alt+shift+f9).
    Last edited by Zer0Cool; 12-11-2017 at 03:09 PM.

  15. #15
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: SUMIFS formula to replace SUMPRODUCT because of ressource issue

    I have already tried that and I had other issues (not with the formula in question but with another formula that I used to count data).
    Can you be specific? What other formula has problems if you change these #N/A errors to "".
    If those formulas can be made to ignore #n/a errors, then they surely can be made to ignore "", and probably more efficiently.

    I honestly think you'll be far better off in the long run if you invest a little time working it out this way.

  16. #16
    Registered User
    Join Date
    01-13-2016
    Location
    Paris
    MS-Off Ver
    Office 2016
    Posts
    12

    Re: SUMIFS formula to replace SUMPRODUCT because of ressource issue

    Thanks for all the suggestions.

    Some questions/remarks :

    1. The lookup function on a column was to retrieve the last numeric value of said column (where there can be blanks, numeric and non-numeric values). That was the only way I found to do so. And I recall having a bunch of those in other worskheets without any issue. Anyhow, would you happen to know of a more efficient way to retrieve the last value of a column ?

    2. Yeah,I did not use sumproduct because the cells are not contiguous and depend on the "region" the country is in (Europe, LatAM...). But since I have a line with those regions, I guess a sumifs with a condition on the regions should work as well.

    3. thanks I will do that. I have tried downloading a addin to remove excess content but it did not seem to work. I guess I can do it manually. Sorry but what's a calc chain ?
    Last edited by lillumultipass; 12-12-2017 at 04:36 AM.

  17. #17
    Registered User
    Join Date
    01-13-2016
    Location
    Paris
    MS-Off Ver
    Office 2016
    Posts
    12

    Re: SUMIFS formula to replace SUMPRODUCT because of ressource issue

    Quote Originally Posted by Jonmo1 View Post
    Can you be specific? What other formula has problems if you change these #N/A errors to "".
    If those formulas can be made to ignore #n/a errors, then they surely can be made to ignore "", and probably more efficiently.

    I honestly think you'll be far better off in the long run if you invest a little time working it out this way.

    Yes, I thought it was because I have another formula that counts the number of times a value at time t is higher than the value at time t-1 for each country. And it did not seem to work with a blank...but I tried it again and it actually worked.
    Hmmm...I have to investigate.


    But so you think a simpler sumproduct without the IF(ISNA) will be less resource-intensive ?
    Yeah, probably so...

  18. #18
    Registered User
    Join Date
    01-13-2016
    Location
    Paris
    MS-Off Ver
    Office 2016
    Posts
    12

    Re: SUMIFS formula to replace SUMPRODUCT because of ressource issue

    Ok I found the issue with the blanks.
    My formula to retrieve the last value of a column does not work if the last cell is a blank (which happens from time to time given that the data for different countries is not available at the same time).

  19. #19
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: SUMIFS formula to replace SUMPRODUCT because of ressource issue

    My formula to retrieve the last value of a column does not work if the last cell is a blank
    What is that formula?

  20. #20
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: SUMIFS formula to replace SUMPRODUCT because of ressource issue

    Anyhow, would you happen to know of a more efficient way to retrieve the last value of a column ?
    Try this to find the last 'numeric' value in a column
    =LOOKUP(9.99999999999999E+307,AG:AG)

    This will be FAR more efficient than
    =LOOKUP(2,1/(NOT(ISBLANK(AG:AG))),AG:AG)
    And it will not care if there are #n/a errors in the range.

  21. #21
    Registered User
    Join Date
    01-13-2016
    Location
    Paris
    MS-Off Ver
    Office 2016
    Posts
    12

    Re: SUMIFS formula to replace SUMPRODUCT because of ressource issue

    Quote Originally Posted by Jonmo1 View Post
    Try this to find the last 'numeric' value in a column
    =LOOKUP(9.99999999999999E+307,AG:AG)

    This will be FAR more efficient than
    =LOOKUP(2,1/(NOT(ISBLANK(AG:AG))),AG:AG)
    And it will not care if there are #n/a errors in the range.

    Ah, thank you that's great !
    Indeed, it works and it even allows me to get the penultimate value when the last one is a blank !
    I have just adjusted the range so that it is only 400 lines.

  22. #22
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: SUMIFS formula to replace SUMPRODUCT because of ressource issue

    You're welcome.

  23. #23
    Forum Expert
    Join Date
    10-02-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    1,222

    Re: SUMIFS formula to replace SUMPRODUCT because of ressource issue

    Quote Originally Posted by lillumultipass View Post
    And I recall having a bunch of those in other worskheets without any issue.
    Just because it worked before doesnt mean its not contributing to the issue. Thats like a burglar getting caught and going "well I used to get away with it".

    If its excess cells, which I have already confirmed you have some, then what happens is the range you actually have data in is smaller (sometimes much smaller) than the actual used range (the range Excel thinks has contents). So even in a formula that may be aware of the used range and not waste resources on a full column reference past the used range, due to the excess cells your used range could be much greater than your actual range adding time to your calculations.

    The analogy I use is this. Imagine I ask you to go out to a parking lot with 10 marked spots (each has a unique ID) and ask you to remember the spots that have cars in them...easy enough. Now lets say I actually want you to remember not only the ones that have cars in them, but all the empty ones as well...thats harder (this is essentially what we ask of Excel, manage our data and manage the empty cells in our used range...the greater the used range the harder it is).

  24. #24
    Registered User
    Join Date
    01-13-2016
    Location
    Paris
    MS-Off Ver
    Office 2016
    Posts
    12

    Re: SUMIFS formula to replace SUMPRODUCT because of ressource issue

    Ok guys, here is a summary of what I have done :

    - remove excess content with an addin
    - replace =LOOKUP(2,1/(NOT(ISBLANK(AG:AG))),AG:AG) with =LOOKUP(9.99999999999999E+307,AG:AG) and reducing the range
    - replace N/As in my formulas by blanks
    - which allowed me to simplify my SUMPRODUCT
    - and replace the inefficient array {=(AG45*AG$4+AH45*AH$4+AO45*AO$4+AY$4*AY45)*SUM(IF(ISNUMBER($AG$4:$BB$4),$AG$4:$BB$4))/($AG$4+$AO$4+$AH$4+$AY$4)} with a sumproduct : =SOMMEPROD(--($AG$5:$BB$5="LatAm");($AG308:$BB308);($AG$4:$BB$4))/SOMMEPROD(--($AG$5:$BB$5="LatAm");--(ESTNUM($AG308:$BB308));($AG$4:$BB$4)) that seeks for additional criteria (i.e., the region of said country).

    I haven't done so for all my worksheet (there a remany) so I will wait a bit before rebuilding the calc chain.
    Anyhow, it seems to be working more smoothly right now...so thanks a lot for your help!

  25. #25
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,432

    Re: SUMIFS formula to replace SUMPRODUCT because of ressource issue

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  26. #26
    Registered User
    Join Date
    01-13-2016
    Location
    Paris
    MS-Off Ver
    Office 2016
    Posts
    12

    Re: SUMIFS formula to replace SUMPRODUCT because of ressource issue

    oh yeah, sorry ! Done ;-)

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Trying to move SUMPRODUCT formula to SUMIFS
    By chimelle in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-20-2015, 05:08 PM
  2. Issue With Not Equal To in SUMIFS Formula
    By Comptka in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 03-06-2015, 02:29 PM
  3. sumifs + offset formula issue
    By jw01 in forum Excel General
    Replies: 6
    Last Post: 02-11-2015, 11:05 AM
  4. [SOLVED] Convert SUMIFS formula to SUMPRODUCT
    By timbury1 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 11-08-2014, 01:18 PM
  5. Sumproduct with sumifs formula
    By nilani in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-22-2014, 08:50 AM
  6. SUMIFS Formula Issue
    By keithd203 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-18-2013, 04:15 PM
  7. Using Sumproduct or sumifs when a cell has a formula
    By cartica in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-15-2013, 04:02 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1