+ Reply to Thread
Results 1 to 9 of 9

function to sum a column's entries based on another column

  1. #1
    Registered User
    Join Date
    02-20-2009
    Location
    Portland, Oregon
    MS-Off Ver
    Excel 2007
    Posts
    8

    function to sum a column's entries based on another column

    Hello. Thanks for reading. I am grateful for your expertise.

    I'm an intermediate excel user, and comfortable with nested if statements and other functions, but there's one task I repeatedly come across that I don't know how to do efficiently.

    Let's say I have a dataset with blank or X in column A, and a dollar value in column B. I want to sum the dollar amounts for column B only if there is a corresponding X in that row in column A. The way I currently do that is by creating a new column C, making a if statement to display the value of B only if there is an entry in A, and then doing operations on that new range. I figure there has to be an easier way. I don't know how to use VLOOKUP, despite trying to read the helpme a bunch of times. Is that relevant?
    Last edited by brickc1; 02-20-2009 at 08:02 PM.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: function to sum a column's entries based on another column

    Maybe like this in one cell:

    =SUMIF($A$1:$A$100,"="&"X",$B$1:$B$100)
    ...or
    =SUMIF(A1:A100,"="&"X",B1:B100)
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    02-20-2009
    Location
    Portland, Oregon
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: function to sum a column's entries based on another column

    Ah, thanks. Yes, that works for SUMIF. It does not appear to work for COUNTIF, in the case that I'm summing the count of string entries. Is there a way to do this easily?

    References I'm stumbling on:

    http://www.ozgrid.com/Excel/sum-if.htm

    http://www.computing.net/answers/off...ions/7208.html

    Thank you.

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: function to sum a column's entries based on another column

    You mean you just want a count of how many Xs there are?

    =COUNTIF($A$1:$A$100,"="&"X")
    Last edited by JBeaucaire; 02-20-2009 at 07:33 PM. Reason: added sample formula

  5. #5
    Registered User
    Join Date
    02-20-2009
    Location
    Portland, Oregon
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: function to sum a column's entries based on another column

    Yes; now I want a count of how many Xs there are in rows where there is a corresponding X in another column.

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: function to sum a column's entries based on another column

    Um, you want a count of how many times an X occurs in one column, but only if there is also an X in a previous column?

    That's something like this, maybe:

    =SUMPRODUCT(--($A$1:$A$100="X"),--($B$1:$B$100="X"))
    Last edited by JBeaucaire; 02-20-2009 at 07:58 PM.

  7. #7
    Registered User
    Join Date
    02-20-2009
    Location
    Portland, Oregon
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: function to sum a column's entries based on another column

    Awesome. I've never used SUMPRODUCT before. for anyone else, I found this short page informative:

    http://www.bygsoftware.com/Excel/fun...sumproduct.htm

  8. #8
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: function to sum a column's entries based on another column

    If that takes care of your need, be sure to EDIT your original post (Go Advanced) and mark the PREFIX box [SOLVED]

  9. #9
    Registered User
    Join Date
    02-20-2009
    Location
    Portland, Oregon
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: function to sum a column's entries based on another column

    Roger, thanks.

+ 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