+ Reply to Thread
Results 1 to 5 of 5

SUMIF - not returning expected result

  1. #1
    Valued Forum Contributor
    Join Date
    06-30-2005
    Location
    Verwood, Dorset, England
    MS-Off Ver
    Excel 2000
    Posts
    479

    SUMIF - not returning expected result

    I have a table similar to below in columns A-D and Rows 1-4, but with many columns (this is simplified), I want the sum of all the data in columns with a column heading of x

    I used this SUMIF formula: =SUMIF(A1:D1,"x",A2:D4) and expected the result to be 16 but got 3

    Have I misunderstood the SUMIF function? What function should I use to get the result I was expecting?

    x y z x
    1 1 1 2
    2 1 3 3
    3 3 4 5
    Last edited by Paul Sheppard; 08-16-2011 at 11:42 AM.
    Paul

  2. #2
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,444

    Re: SUMIF - not returning expected result

    Hi,


    Try sumproduct instead

    =SUMPRODUCT((A2:D4)*(A1:D1="x"))
    Rule 1: Never merge cells
    Rule 2: See rule 1

    "Tomorrow I'm going to be famous. All I need is a tennis racket and a hat".

  3. #3
    Valued Forum Contributor
    Join Date
    06-30-2005
    Location
    Verwood, Dorset, England
    MS-Off Ver
    Excel 2000
    Posts
    479

    Re: SUMIF - not returning expected result

    Thx Sweep that's great, but why doesn't SUMIF work, in my example it seems to only add the first row

  4. #4
    Forum Expert Colin Legg's Avatar
    Join Date
    03-30-2008
    Location
    UK
    MS-Off Ver
    365
    Posts
    1,256

    Re: SUMIF - not returning expected result

    To use SUMIF you have to do it like this (or variation thereof):
    Please Login or Register  to view this content.
    This is because the dimensions of the criteria range (A1:D1) define the dimensions of the sum range. If the criteria range is 1 row deep, then the sum range will be internally recalculated within the function so it is only 1 row deep too. See section 3.2 here for a full explanation.



    Of course, you could have a totals row in row 5, and then reference the totals row in your SUMIF formula. So in cell A5 put this:
    Please Login or Register  to view this content.
    and copy across. Then your SUMIF formula becomes
    Please Login or Register  to view this content.
    Hope that helps,

    Colin

    RAD Excel Blog

  5. #5
    Valued Forum Contributor
    Join Date
    06-30-2005
    Location
    Verwood, Dorset, England
    MS-Off Ver
    Excel 2000
    Posts
    479

    Re: SUMIF - not returning expected result

    Thanks Colin

+ 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