+ Reply to Thread
Results 1 to 16 of 16

SUMPRODUCT suggestion to speed up

  1. #1
    Registered User
    Join Date
    04-05-2016
    Location
    India
    MS-Off Ver
    2013
    Posts
    78

    SUMPRODUCT suggestion to speed up

    I have a data field from D1 to ND1 as 16-02-2018 to 15-02-2019 (365 days). I have data from D2 to ND611. I have used SUMPRODUCT formula in two sheets TOTAL and MONTH_WISE which helps to get the output data total and also month-wise based on FROM and TO dates setup in TOTAL sheet.
    The formula is correct and I have verified it. But, it is slow when I am entering the data. I understand that since SUMPRODUCT works array logic, it consumes time. Any suggestions on improving the speed?

    The work file is attached herewith
    Attached Files Attached Files

  2. #2
    Forum Expert shukla.ankur281190's Avatar
    Join Date
    05-17-2014
    Location
    Lucknow, India
    MS-Off Ver
    Office 365
    Posts
    3,935

    Re: SUMPRODUCT suggestion to speed up

    You can change your month_wise sheet formula as below.

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


    copy across
    If I helped, Don't forget to add reputation (click on the little star ★ at bottom of this post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)

  3. #3
    Registered User
    Join Date
    04-05-2016
    Location
    India
    MS-Off Ver
    2013
    Posts
    78

    Re: SUMPRODUCT suggestion to speed up

    Thanks, I appreciate the brevity introduced in the formula. There is no appreciable improvement in speed. I know “speed” is a relative term. Eager to know if we can use SUMIFS for this purpose.

  4. #4
    Forum Expert shukla.ankur281190's Avatar
    Join Date
    05-17-2014
    Location
    Lucknow, India
    MS-Off Ver
    Office 365
    Posts
    3,935

    Re: SUMPRODUCT suggestion to speed up

    Ok Try

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


    This formula would not much efficient but as per your requirement it would work smoothly

  5. #5
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: SUMPRODUCT suggestion to speed up

    You could use (TOTAL G5)

    =SUMIFS(INDEX(data!$D$2:$ND$650,MATCH([@[Part Flag]],data!$A$2:$A$650,0),0),data!$D$1:$ND$1,">="&$B$1,data!$D$1:$ND$1,"<="&$B$2)

    The same approach could be applied to any other similar sumproduct formula.
    Last edited by jason.b75; 12-28-2018 at 07:09 AM. Reason: typo

  6. #6
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: SUMPRODUCT suggestion to speed up

    Looking at your sample file in more detail, I just noticed that the dates in row 5 of your month_wise sheet are not proper dates, so a little more manipulation is required there.

    In E6, then drag / fill the table to Q615

    =SUMIFS(INDEX(data!$D$2:$ND$650,MATCH([@[Part Flag]],data!$A$2:$A$650,0),0),data!$D$1:$ND$1,">="&DATEVALUE(1&E$5),data!$D$1:$ND$1,"<="&EOMONTH(DATEVALUE(1&E$5),0))

    Also, given that the TOTAL sheet appears to be just that, the dates there are moot. You just need

    =SUM(INDEX(data!$D$2:$ND$650,MATCH([@[Part Flag]],data!$A$2:$A$650,0),0))

    Or, even simpler, because it is already calculated in the month_wise sheet, just get the existing total from there with

    =INDEX(MNT[Qty Total],MATCH([@[Part Flag]],MNT[Part Flag],0))

  7. #7
    Registered User
    Join Date
    04-05-2016
    Location
    India
    MS-Off Ver
    2013
    Posts
    78

    Re: SUMPRODUCT suggestion to speed up

    Thanks, Mr. Jason. I tried these formula and also understood how it works.

    1. In the MONTH_WISE sheet, it is only the month is significant to me. Hence, I formatted it as Feb-2018, Mar-2018 and so on. As it was in text format, I understand you had to pad it with number and use DATEVALUE function to get the month-wise sum.

    2. The fact that OUTPUT sheet is nothing but assimilated form of MONTH_WISE sheet is also insightful. Hence, the INDEX-MATCH formula you suggested is the best choice.

    3. If you observed, my objective was to get the month-wise total between custom dates which I enter in FROM (Cell C1 of MONTH_WISE sheet) and TO (Cell C2 of MONTH_WISE sheet). However, the formula provided by you considers the entire month and is not dependent on dates as I wish.

    I tried modifying the formula as follows, but the results are erroneous when I apply to other columns
    =SUMIFS(INDEX(data!$D$2:$ND$650,MATCH([@[PartFlag]],data!$A$2:$A$650,0),0),data!$D$1:$ND$1,">="&INT($C$1),data!$D$1:$ND$1,"<="&EOMONTH(DATEVALUE(1&E$5),0),data!$D$1:$ND$1,"<="&INT($C$2),data!$D$1:$ND$1,"<="&EOMONTH(DATEVALUE(1&E$5),0))

    The formula is applied in sheet MONTH_WISE_TEST and can be found in the work file attached herewith. Could you please help trace where I am going wrong?
    Attached Files Attached Files
    Last edited by melvinkoshy; 12-28-2018 at 12:14 PM.

  8. #8
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: SUMPRODUCT suggestion to speed up

    Using your method, the formula in E6 should be

    =SUMIFS(INDEX(data!$D$2:$ND$650,MATCH($B6,data!$A$2:$A$650,0),0),data!$D$1:$ND$1,">="&$C$1,data!$D$1:$ND$1,">="&DATEVALUE(1&E$5),data!$D$1:$ND$1,"<="&$C$2,data!$D$1:$ND$1,"<="&EOMONTH(DATEVALUE(1&E$5),0))

    The extra EOMONTH function, along with <= instead of >= was comparing wrong dates.
    INT() was not needed, you only need to use that to sepatate date from time when you have both together.

    This method might be slightly faster to calculate, not the use of MAX and MIN to determine the correct start and end dates to reduce the number of criteria in sumifs.

    =SUMIFS(INDEX(data!$D$2:$ND$650,MATCH($B6,data!$A$2:$A$650,0),0),data!$D$1:$ND$1,">="&MAX($C$1,DATEVALUE(1&E$5)),data!$D$1:$ND$1,"<="&MIN($C$2,EOMONTH(DATEVALUE(1&E$5),0)))

    Faster still, would be to enter this formula into A6 and fill down

    =MATCH(MNT_4[@[Part Flag]],data!$A$2:$A$611,0)

    Then use this in E6 to fill the table

    =SUMIFS(INDEX(data!$D$2:$ND$650,$A6,0),data!$D$1:$ND$1,">="&MAX($C$1,DATEVALUE(1&E$5)),data!$D$1:$ND$1,"<="&MIN($C$2,EOMONTH(DATEVALUE(1&E$5),0)))

    Which will significantly reduce the number of times an exact match needs to be calulated, which by now is one of the biggest drains on calculation resources.

    Note that with any one of these formulas in the month_wise sheet, the figure in the TOTAL sheet will be the total from the custom dates entered in month_wise, not the total of the whole sheet.

    To get the total of the whole sheet regardless of the custom dates, you would need the SUM(INDEX formula from my previous post.

  9. #9
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: SUMPRODUCT suggestion to speed up

    If you Part Flag in Data and month_wise sheet are in the same sequence as it is.

    Please try at month_wise E6

    =SUMIFS(data!$D2:$ND2,data!$D$1:$ND$1,">="&--(E$5),data!$D$1:$ND$1,"<="&EOMONTH(--(E$5),0))

    month_wise_TEST E6

    =SUMIFS(data!$D2:$ND2,data!$D$1:$ND$1,">="&MAX($C$1,--(E$5)),data!$D$1:$ND$1,"<="&MIN($C$2,EOMONTH(--(E$5),0)))

  10. #10
    Registered User
    Join Date
    04-05-2016
    Location
    India
    MS-Off Ver
    2013
    Posts
    78

    Re: SUMPRODUCT suggestion to speed up

    Quote Originally Posted by jason.b75 View Post
    Using your method, the formula in E6 should be

    =SUMIFS(INDEX....

    Jason,
    I tried both options and works as desired. Perhaps, I messed up with the “<=” & “>=” sign with dates with the use of INT, which was not the right thing to use.
    I understood how referring the ‘Partflag’ field helps reduce iterations.
    The use of INDEX-MATCH with SUMIFS was incisive. I also set the calculation as MANUAL instead of the default automatic.
    This method is way better than SUMPRODUCT which consumes time. SUMPRODUCT is so convenient that we tend to use it often and not mindful of the fact that it consumes time.
    Thanks for the wonderful explanation.

  11. #11
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: SUMPRODUCT suggestion to speed up

    Why set calculation to manual, when you can speed it up even more? This method eliminates sumifs calculation where it is not needed, i.e. months outside of the range specified in C1 and C2. Making it almost instant if the dates only cover a short period (If the 'To Date' in C2 is empty, no sumifs calcs are performed, so a quick way to speed up data entry)

    It also includes efficient elimination of the #N/A errors that you will have in various places.

    A list of the formulas used, already entered in the attached copy of your file.

    month_wise sheet
    E1, fill right to Q1
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    E2, then fill right to Q2
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    A6, down to A615
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    C6, right to D6, then down to C615 & D615
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    E6, right and down to Q615
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    D6, down to R615
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    S6, down to S615
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    TOTAL sheet, as this is a direct copy of select columns of the month_wise sheet, all index / match functions can be removed here and replace with a very simple formula.
    B3, right and down to D636
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    E3, right and down to F636
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    I think that it could possibly be further improved by using MATCH to get column numbers instead of dates in row 1 of month_wise, meaning that you could then use SUM(INDEX( which would be more efficient than SUMIFS, but I can't get the logic to function correctly.
    Attached Files Attached Files

  12. #12
    Registered User
    Join Date
    04-05-2016
    Location
    India
    MS-Off Ver
    2013
    Posts
    78

    Re: SUMPRODUCT suggestion to speed up

    Quote Originally Posted by jason.b75 View Post
    Why set calculation to manual, when you can speed it up even more? ....
    Thanks for taking time to understand my requirement and simplifying the problem even further. With all suggestions into account, the sheet works charm. Included a few custom requirements with VBA also
    Thanks a lot once again.

  13. #13
    Forum Expert avk's Avatar
    Join Date
    07-12-2007
    Location
    India
    MS-Off Ver
    Microsoft Office 2013
    Posts
    3,222

    Re: SUMPRODUCT suggestion to speed up

    As per my view no need of total sheet. Because in monthwise sheet already calculate total qty & amount.
    Secondly, plz explain about part flag & Sl no.


    atul


    If my answer (or that of other members) has helped you, please say "Thanks" by clicking the Add Reputation button at the foot of one of their posts.

    Also: if your problem is solved, please take the time to mark your thread as SOLVED by going to the top of your first post, selecting "Thread Tools" and then "Mark thread as solved".

  14. #14
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: SUMPRODUCT suggestion to speed up

    Quote Originally Posted by avk View Post
    As per my view no need of total sheet. Because in monthwise sheet already calculate total qty & amount.
    How would you go about printing the data on the Total sheet from the month_wise sheet?

  15. #15
    Forum Expert avk's Avatar
    Join Date
    07-12-2007
    Location
    India
    MS-Off Ver
    Microsoft Office 2013
    Posts
    3,222

    Re: SUMPRODUCT suggestion to speed up

    The matter is only speed up of calculation.

  16. #16
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: SUMPRODUCT suggestion to speed up

    Which is what I did, the TOTAL worksheet was already there in the sample provided (See post #1). All I did was speed it up, nothing added , nothing taken away.

    If the question about part flag and Sl no was directed at me, then again, this was part of the original, I don't think that I changed it, the existing formula was simple and efficient.

+ 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. DGET speed and suggestion for improvement?
    By froment in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 03-30-2015, 03:34 PM
  2. Speed up or workaround SUMPRODUCT() Macro
    By Hieronymus5 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-30-2014, 07:16 AM
  3. [SOLVED] SUMPRODUCT Killing the speed
    By uakhan in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-21-2013, 11:42 AM
  4. Modification suggestion(s) to speed up my code
    By VKS in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-14-2013, 06:28 AM
  5. Speed Up calculations - sumproduct
    By Risels7 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 01-03-2013, 11:51 PM
  6. SUMPRODUCT calculation speed issues
    By richardj in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-12-2012, 07:40 PM
  7. [SOLVED] Code to speed up sumproduct formulas
    By tbeast in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-27-2012, 05:14 PM

Tags for this Thread

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