+ Reply to Thread
Results 1 to 10 of 10

Advanced SumIf criteria

  1. #1
    Registered User
    Join Date
    10-18-2008
    Location
    Sweden
    Posts
    16

    Advanced SumIf criteria

    Hello!

    I've come up with a solution for summing the values of column B if the corresponding value in column A contains a substring that matches any of the values in a given list of strings, here the named range 'Matbutiker', which requires me to put either 0 or the value in a new column using the following formula:

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


    , populating the entire column for the entire range, A3:A24 and B3:B24, and then summing over that column. In my case I get entire E3:E24 full of irrelevant partial calculations.

    What I really want to do is, since I'm only interested in the resulting sum and not the partials, is to put this condition in a SumIf formula to avoid having to spend and hide an entire column for this.

    This is what I imagine I would be able to do:

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


    If any of the entries in A3:A24 contains a substring of any of the strings in the named range Matbutiker, sum the corresponding value in B3:B24. Obviously the formula above doesn't work and I think the problem lies within the
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    , which can't handle arrays?

    Can I somehow generate an array out of this condition so I can sum over it without explicitly having to do the partial calculations in another column? Please any hints or tips would be appreciated - I've wrestled with this for far too long!

    Regards,
    Daniel

  2. #2
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,146

    Re: Advanced SumIf criteria

    Try (Engish version!)

    =SUMPRODUCT(((--ISNUMBER(SEARCH(Matbutiker,A3:A24)))>0)*(B3:B24))

    Matches named range "Matbutiker" with A3:A34 and SUMS column B3:B34

    OR

    =SUMPRODUCT(((--ISNUMBER(SEARCH(Matbutiker,A3:A24)))*(B3:B24)))
    Last edited by JohnTopley; 04-02-2017 at 10:47 AM. Reason: Extra test removed

  3. #3
    Registered User
    Join Date
    10-18-2008
    Location
    Sweden
    Posts
    16

    Re: Advanced SumIf criteria

    Quote Originally Posted by JohnTopley View Post
    Try (Engish version!)

    =SUMPRODUCT(((--ISNUMBER(SEARCH(Matbutiker,A3:A24)))>0)*(B3:B24))

    Matches named range "Matbutiker" with A3:A34 and SUMS column B3:B34

    OR

    =SUMPRODUCT(((--ISNUMBER(SEARCH(Matbutiker,A3:A24)))*(B3:B24)))
    Thanks for the reply!

    I have in fact tried similar solutions already but they (the search function I guess) don't seem to work as I want them to with the array formula (ctrl + shift + enter). Does that particular formula work for you and have I just messed up syntax? Your suggestion gives me 0 sadly.

    Regards,
    Daniel

  4. #4
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,146

    Re: Advanced SumIf criteria

    It worked if I understood your requirement.

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.

  5. #5
    Registered User
    Join Date
    10-18-2008
    Location
    Sweden
    Posts
    16

    Re: Advanced SumIf criteria

    Thanks,

    I don't think you've misunderstood the question and I also feel like it should work. See the attachment for clarification.

    I don't know if there's a bug in my Excel or something because just now I got it to work for SOME cells . See if you can get the formulas to work in the sheet. It might be the Swedish version that's buggy?

    Regards,
    Daniel
    Attached Files Attached Files

  6. #6
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,899

    Re: Advanced SumIf criteria

    Try this ...

    =SUMPRODUCT(SUMIF(A2:A7,D11:D14,B2:B7))

  7. #7
    Registered User
    Join Date
    10-18-2008
    Location
    Sweden
    Posts
    16

    Re: Advanced SumIf criteria

    Quote Originally Posted by Phuocam View Post
    Try this ...

    =SUMPRODUCT(SUMIF(A2:A7,D11:D14,B2:B7))
    Hi, thanks for responding!

    I think I forgot to mention that of course the "search" part of the formula is important since I'm interested in finding entries which contain the substring from the named range 'Matbutiker', or D11:D14 in your case.

    Cheers,
    Daniel

  8. #8
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,146

    Re: Advanced SumIf criteria

    Try

    =SUMPRODUCT(((--ISNUMBER(SEARCH(TRANSPOSE(Matbutiker),A2:A24)))*(B2:B24)))

    Enter with Ctrl+Shift+Enter
    Attached Files Attached Files
    Last edited by JohnTopley; 04-03-2017 at 04:38 AM.

  9. #9
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,899

    Re: Advanced SumIf criteria

    Quote Originally Posted by pkaff View Post
    finding entries which contain the substring
    =SUMPRODUCT(SUMIf(A2:A7,"*"&D11:D14&"*",B2:B7))

  10. #10
    Registered User
    Join Date
    10-18-2008
    Location
    Sweden
    Posts
    16

    Re: Advanced SumIf criteria

    Quote Originally Posted by Phuocam View Post
    =SUMPRODUCT(SUMIf(A2:A7,"*"&D11:D14&"*",B2:B7))
    Yes, perfect this works! And it's so much simpler!! Thanks a lot!

    Also thanks to you JohnTopley for trying to figure out the syntax for that other formula. I think that should work as well, but even with the transpose I get an error.

    Cheers,
    Daniel

+ 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. [SOLVED] Advanced COUNTIF and SUMIF
    By ManinOZ in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-31-2015, 05:14 AM
  2. [SOLVED] Shorten SUMIF + SUMIF + SUMIF each with same reference range but different criteria???
    By HeyInKy in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 04-13-2014, 09:25 PM
  3. [SOLVED] SUMIF advanced....
    By alfgrey in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-06-2014, 08:21 PM
  4. [SOLVED] SUMIF advanced
    By alfgrey in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 10-14-2013, 09:36 AM
  5. advanced SUMIF problems
    By m.velin in forum Excel General
    Replies: 3
    Last Post: 12-15-2010, 12:51 PM
  6. Help with Advanced Filters and Sumif's
    By Pelona in forum Excel General
    Replies: 6
    Last Post: 07-28-2009, 03:41 PM
  7. Help on Advanced Sumif
    By paid2mkgrlspanic in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-14-2009, 03:35 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