+ Reply to Thread
Results 1 to 3 of 3

Thread: Sumproduct for two different categories

  1. #1
    Registered User
    Join Date
    04-10-2011
    Location
    Boston, MA
    MS-Off Ver
    Excel 2007
    Posts
    2

    Sumproduct for two different categories

    Hi everyone,

    I have a number of transactions in Excel listed in columns A-C (security, quantity and date). Based on specific dates and security names in columns G and H, I was trying to figure out a way to sum up all the transaction for a given name that happened up to (and including) that date. I am using this formula, but the results I got seem to wrong.

    SUMPRODUCT(--(A$1:A$100=H$5),--(C$1:C$100>=G$5),--(B$1:B$100))

    If anyone could please take a look and let me know where things went wrong, it would be a huge help.
    Attached Files Attached Files

  2. #2
    Forum Moderator DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Suffolk, UK
    MS-Off Ver
    2002, 2007 & 2010
    Posts
    21,423

    Re: Sumproduct for two different categories

    Your current calculation is summing values >= date specified rather than <= date specified which is I suspect what you want.

    Other notes re: existing SUMPRODUCT:

    The coercion of the value range (B1:B100) is not necessary and indeed negates one of the main advantages of double unary on the boolean arrays
    Your use of $ is I think the wrong way around if you intend to apply the formula in J5 to remaining rows

    Given all of the above I'd suggest:

    J5:
    =SUMPRODUCT(--($A$1:$A$100=$H5),--($C$1:$C$100<=$G5),$B$1:$B$100)
    copied down
    If using XL2007 or above (exclusively) then revert to SUMIFS which is significantly more efficient than SUMPRODUCT

    J5:
    =SUMIFS($B$1:$B$100,$A$1:$A$100,$H5,$C$1:$C$100,"<="&$G5)
    copied down

  3. #3
    Registered User
    Join Date
    04-10-2011
    Location
    Boston, MA
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Sumproduct for two different categories

    Thank you very much! Both formulas work for me, but we're in the middle of upgrading from Excel 2003 to 2007 at work, so I think I'll keep using sumproduct, even if it is more inefficient.

    Thanks again for the prompt reply.

+ 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.2.0