+ Reply to Thread
Results 1 to 6 of 6

Baffled by SumIf issue.

  1. #1
    Registered User
    Join Date
    10-02-2013
    Location
    Chicago
    MS-Off Ver
    Excel 2010
    Posts
    2

    Baffled by SumIf issue.

    I kept getting issues on counts lately between a list I would simply =sum, and then trying to verify after performing a =sumif function.

    I was able to track it down to two line items:

    ICBLTC8-B11 + ICBPTC8-B12 *WINDOW*
    ICBLTC8-B11 + ICBPTC8-B12 + B148-C11B *WINDOW*

    The quantities are 3 and 2 respectively.
    ICBLTC8-B11 + ICBPTC8-B12 *WINDOW* 3
    ICBLTC8-B11 + ICBPTC8-B12 + B148-C11B *WINDOW* 2


    I took it to another column and did the following:
    =SUMIF($D$1:$D$2,$G$1:$G$2,$E$1:$E$2)


    And this is the result I get:
    ICBLTC8-B11 + ICBPTC8-B12 *WINDOW* 5
    ICBLTC8-B11 + ICBPTC8-B12 + B148-C11B *WINDOW* 2


    So it looks like the SumIF is reading both as identical for the purposes of the shorter item, but not the longer one. How the heck do I avoid this?

  2. #2
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Baffled by SumIf issue.

    =SUMIF($D$1:$D$2,$G$1:$G$2,$E$1:$E$2) isnt the correct format for sumif
    SUMIF(range, criteria, [sum_range])
    from help files
    =SUMIF(B2:B5, "John", C2:C5) sums only the values in the range C2:C5, where the corresponding cells in the range B2:B5 equal "John."
    you cant have a range for the criteria
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  3. #3
    Registered User
    Join Date
    10-02-2013
    Location
    Chicago
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Baffled by SumIf issue.

    What I'm doing is this:

    I have a list of 1000+ line items.
    In another column I copy the name column and do a "remove duplicates"
    Then I do the sum if, where column "A" is the names, column "b" is the quantity sold, and column "D" (for example) is my list with duplicates removed. In column "e" I do the sumif. So as to not do it over 100 times (the size of the paired down line items), I did the $. If I remove it, won't the list simply stop looking for all of the line items and find the name of one and that's it?

  4. #4
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Baffled by SumIf issue.

    Attach a sample workbook. Make sure there is just enough data to make it clear what is needed. 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 demonstrated, mock them up manually if needed. Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic

  5. #5
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,504

    Re: Baffled by SumIf issue.

    Agree w/Martin, but from what you've written (and his first reply is still correct) you can just replace =SUMIF(B2:B5, "John", C2:C5) "John" with the cell reference you have your distinct list - of course one cell at a time.
    So if your criteria is in, say cell d2 you point the formula to... =SUMIF(B2:B5, D2 , C2:C5) and just go from there down the list, so it might look like =SUMIF($B$2:$B$1000, D2, $C$2:$C$1000)
    Make contributors happy, click on the "* Add Reputation" as a way to say thank you.
    Sam Capricci

  6. #6
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Baffled by SumIf issue.

    Quote Originally Posted by MLocke View Post
    So it looks like the SumIF is reading both as identical for the purposes of the shorter item, but not the longer one. How the heck do I avoid this?
    The problem is with the asterisks - SUMIF thinks that these are "wildcards" not literal asterisks so it identifies different items as the same

    Use a SUBSTITUTE function in the criterion so instead of this.....

    =SUMIF($D$1:$D$2,$G$1,$E$1:$E$2)

    ....you can use this.....

    =SUMIF($D$1:$D$2,SUBSTITUTE($G1,"*","~*"),$E$1:$E$2)

    That will replace any asterisk in the criterion value with "~*" whereby the ~ [tilde] tells excel to treat the asterisk as a literal asterisk. It works even if there are no *s present.

    ....or you can use SUMPRODUCT instead of SUMIF like this

    =SUMPRODUCT(($D$1:$D$2=$G1)+0,$E$1:$E$2)

    SUMPRODUCT won't recognise * as a wildcard so the problem doesn't occur with that function
    Last edited by daddylonglegs; 10-02-2013 at 03:33 PM.
    Audere est facere

+ 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. Baffled Beginner/Intermediate Excel User
    By michaelaz21 in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 05-28-2013, 08:19 PM
  2. [SOLVED] Excel 2007 : Baffled by the (lack of) result of a countif
    By neil40 in forum Excel General
    Replies: 1
    Last Post: 04-01-2012, 06:43 AM
  3. Strange Vlookup result - baffled
    By andycaps in forum Excel General
    Replies: 9
    Last Post: 01-18-2012, 08:58 AM
  4. Calculation in cell not updating - Totally baffled!
    By bmunoz64 in forum Excel General
    Replies: 1
    Last Post: 01-11-2012, 12:08 PM
  5. [SOLVED] thoroughly-baffled by InStr function w/ binary compare
    By terry b in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-11-2005, 01:06 AM

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