+ Reply to Thread
Results 1 to 3 of 3

Sumproduct - Alternative

  1. #1
    Registered User
    Join Date
    01-18-2007
    Posts
    81

    Sumproduct - Alternative

    Hello.

    I have a template that looks at for 4 variables from a data sheet (See Attached)

    At the moment I’m using SUMPRODUCT, which works, but unfortunately when reading 50,000+ lines it becomes so slow to calculate all the data, especially since there is more than 1 location.

    Is there another formula that can give the same result?, or code that can do it really quickly?

    Cheers
    Attached Files Attached Files

  2. #2
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885
    Due to the way your data sheet is setup, neat columns and rows of like data, a Pivot Table would be far more efficient than using 200 SUMPRODUCT formulas over 50,000+ rows.

    Review the attached sheet. I deleted your Template sheet with all the formulas and created a Sheet1, which has a PivotTable on it. I also duplicated your data so there were about 60,000 rows to test the speed. (To upload the revised sheet I had to delete most of the rows, though.)

    All you would have to do when adding/removing data from the Data sheet is go to the pivot table sheet, click anywhere inside the pivot table and then click Data -> Refresh Data. It will update your numbers within a few seconds at most.

    If you have multiple locations, dates, types, etc. you would simply just use the pivot table to filter your data. The grand totals rows can be set to count the data (# of entries), sum the data, average, etc..

    Hopefully that will work for you.
    Attached Files Attached Files

  3. #3
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Sumproduct - Alternative

    Pivot Tables are designed to do just what you're looking for.


    <Data><Pivot Table>
    Use: Excel
    Select your data, including headings from the Data sheet
    Click the [Layout] button

    PAGE: Drag the Location field here
    ROW: Drag the Type field here
    COLUMN: Drag the DATE field here
    DATA: Drag the Total field here
    -If it doesn't list as Sum of Total...dbl-click it and set it to Sum
    Click [OK]
    Select where you want the Pivot Table...and you're done!

    That will list
    -each Type down the left side
    -each Date across the top
    -and calculate the total for each intersection of those two.

    The default Page setting is to display totals for ALL locations, but to see just one Location, click the dropdown and choose one.

    To refresh the Pivot Table, just right click it and select Refresh Data

    If the rows in the data range may vary, consider basing the Pivot Table on a Dynamic Range Name. For instructions, see Debra Dalgleish's website:
    http://www.contextures.com/xlNames01.html#Dynamic

    Using your data and that above method, here's a sample fo the values I received:
    Please Login or Register  to view this content.
    Is that something you can work with?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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