+ Reply to Thread
Results 1 to 5 of 5

Multiple conditions in one column for sumproduct.

  1. #1
    Registered User
    Join Date
    08-07-2011
    Location
    Bristol, England
    MS-Off Ver
    Excel 2007
    Posts
    4

    Multiple conditions in one column for sumproduct.

    Hi guys,

    I've been trying to enter multiple conditions in sumproduct formula for one column (A3:A3000). This one works, but is there a way to shorten it?

    (SUMPRODUCT(--(DXB!A3:A3000="PM"),--(DXB!C3:C3000=1), DXB!G3:G3000))+(SUMPRODUCT(--(DXB!A3:A3000="NM"),--(DXB!C3:C3000=1), DXB!G3:G3000))

    I essentially added two different sumproduct formulae here, but all i need for it to do is recognize both "PM" and "NM" in A3:A3000 column. A3:A3000={"PM,"NM"} doesnt work, tried.

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Multiple conditions in one column for sumproduct.

    If as implied you are using XL2007 then you should be using SUMIFS rather than SUMPRODUCT - the latter is inefficient:

    Please Login or Register  to view this content.
    In SUMPRODUCT terms, either:

    Please Login or Register  to view this content.
    or

    Please Login or Register  to view this content.
    or

    Please Login or Register  to view this content.
    I prefer the first option in terms of flexibility.

  3. #3
    Registered User
    Join Date
    08-07-2011
    Location
    Bristol, England
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Multiple conditions in one column for sumproduct.

    Thanks! This was brilliant, I wasnt aware of SUMIFS before.

    A quick follow-up question, is it possible (and how) to expand sum_range to more than one column? For instance, in

    =SUM(SUMIFS(DXB!G3:G3000,DXB!A3:A3000,{"PM","NM"},DXB!C3:C3000,1))

    can I use sum_ranges of like G3:H3000, I tried just typing that in and I get #VALUE error. I basically want it to calculate a sum of given items in two columns, not one.

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Multiple conditions in one column for sumproduct.

    For SUMIFS the dimensions of each range must be identical.

    Here it seems you have 2 criteria columns which are 1 column wide therefore your summation range must also be 1 column wide.
    You would need to create 2 separate SUMIFS - one for each column of the summation range - this is not ideal obviously
    (in fact you would be running 4 SUMIFS - PM x 2, NM x 2)

    You may then choose to revert to SUMPRODUCT, perhaps along the lines of:

    Please Login or Register  to view this content.
    the above would handle non-numerics in G3:H3000 (avoids explicit coercion of summation range)

    else consider adding a total column which sums G:H and use that in the SUMIFS.
    Last edited by DonkeyOte; 08-07-2011 at 03:38 AM. Reason: typo

  5. #5
    Registered User
    Join Date
    08-07-2011
    Location
    Bristol, England
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Multiple conditions in one column for sumproduct.

    Brilliant. Thank you a lot. Never wouldve figured that out on my own.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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