+ Reply to Thread
Results 1 to 15 of 15

Trying to use SUMIFS to sum a column based on two conditions

  1. #1
    Registered User
    Join Date
    11-03-2009
    Location
    Ohio
    MS-Off Ver
    Excel 2003
    Posts
    14

    Trying to use SUMIFS to sum a column based on two conditions

    Hello all!

    I would like to use a SUMIFS statement to sum up a column of numbers based on two conditions. The first condition is a word. I have this done. The second condition is going to be a two week date range, which I am having problems solving.

    Here is my formula that works so far.
    =SUMIF(Data!C:C,"Office",Data!D:D)

    Now I would like to SUMIF a second condition is met. The second condition is a date and time in this format.
    1/9/2010 9:21:49 AM

    I am only concerned about the date. Time does not matter. I cannot figure out how to specify a date range for the second condition. I am trying to specify between 1/1/2010 and 1/14/2010 as a test. So here is what I have so far with a SUMIFS.

    =SUMIFS(Data!D:D,Data!C:C,"Office",Data!A:A,"Cannot figure out how to specify dates")

    Maybe my logic is wrong...maybe I need to do three conditions? Where column A has a date < 1/14/2010 and a condition that specifies a date > 1/1/2010.

    All help is appreciated, let me know what you think. Oh and Data! is the worksheet in case that throws anyone off.

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

    Re: Trying to use SUMIFS to sum a column based on two conditions

    Are you using XL2007 or XL2003 (profile) - if not XL2007 then SUMIFS is not available to you.

  3. #3
    Registered User
    Join Date
    11-03-2009
    Location
    Ohio
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: Trying to use SUMIFS to sum a column based on two conditions

    I am using 2007 to work on the statement, but I will be using the formula on Google docs spreadsheet. And you are right, Google Spreadsheet does not recognize SUMIFS as a function. I will have to rework this...

  4. #4
    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,454

    Re: Trying to use SUMIFS to sum a column based on two conditions

    Hi,

    Either with 2003 or 2007, this should work...

    =SUMPRODUCT((Data!D:D)*(Data!C:C="Office")*(Data!A:A<DATE(2010,1,14))*(Data!A:A>DATE(2010,1,1)))

    Think about dynamic ranges - full column calculations are inefficient.
    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".

  5. #5
    Forum Expert contaminated's Avatar
    Join Date
    05-07-2009
    Location
    Baku, Azerbaijan
    MS-Off Ver
    Excel 2013
    Posts
    1,430

    Re: Trying to use SUMIFS to sum a column based on two conditions

    Maybe

    Please Login or Register  to view this content.
    Люди, питающие благие намерения, как раз и становятся чудовищами.

    Regards, ?Born in USSR?
    Vusal M Dadashev

    Baku, Azerbaijan

  6. #6
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,375

    Re: Trying to use SUMIFS to sum a column based on two conditions

    If indeed you have Excel 2007, your SUMIFS could develop along this schema

    =SUMIFS(Data!D:D,Data!C:C,"Office",Data!A:A,">="&B1,A:A,"<="&B2)

    with B1 being the smallest allowable date and B2 being the biggest allowable date.

    If that does not help, please post a workbook and specify your Excel version.

  7. #7
    Registered User
    Join Date
    11-03-2009
    Location
    Ohio
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: Trying to use SUMIFS to sum a column based on two conditions

    Thanks for all of your replies. For some reason SUMPRODUCT did seem like the most logical function to use. But it is an array function and Google Spreadsheet does not have SUMIFS function built in yet. I'll have to go with sweeps answer as the best for this situation.

    Thanks everyone.

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

    Re: Trying to use SUMIFS to sum a column based on two conditions

    Quote Originally Posted by sweep
    Either with 2003 or 2007, this should work...

    =SUMPRODUCT((Data!D:D)*(Data!C:C="Office")*(Data!A:A<DATE(2010,1,14))*(Data!A:A>DATE(2010,1,1)))
    FWIW the above would not work pre XL2007 given use of entire column references (#NUM!) - but as you say you should keep ranges as lean as possible anyway.

  9. #9
    Registered User
    Join Date
    11-03-2009
    Location
    Ohio
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: Trying to use SUMIFS to sum a column based on two conditions

    Yes I did notice. I am looking at the ins and outs right now.

    The function is returning zeros. But think that is because of the date condition. The cell that I am working with is not a date formatted cell. But really just a text time stamp of when the information was submitted. I think I might need a little help on that.

    If possible, could someone also post the name of the DATE(2010,1,1) condition. I want to Google more of these formatted condition statements.

    Thanks

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

    Re: Trying to use SUMIFS to sum a column based on two conditions

    Generally speaking a sample file speaks a dozen posts...

  11. #11
    Registered User
    Join Date
    11-03-2009
    Location
    Ohio
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: Trying to use SUMIFS to sum a column based on two conditions

    Sorry, yes a file does speak a thousand posts. The file is attached.

    Thanks again for your support.
    Attached Files Attached Files

  12. #12
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,706

    Re: Trying to use SUMIFS to sum a column based on two conditions

    You should be able to use a version of SUMPRODUCT as suggested by sweep, i.e.

    =SUMPRODUCT(Data!D2:D100,(Data!C2:C100="Office2")*(Data!A2:A100<DATE(2010,1,14))*(Data!A2:A100>DATE(2010,1,1)))

    With SUMIFS that would be

    =SUMIFS(Data!D2:D100,Data!C2:C100,"Office2",Data!A2:A100,"<"&DATE(2010,1,14),Data!A2:A100,">"&DATE(2010,1,1))

    Note: neither of those will include the referenced dates, i.e. 1st and 14th Jan, if you want to include them then you would need to use >= on the 1st and change 14th to 15th for the second (can't do <= 14th because you have times in the data)
    Last edited by daddylonglegs; 01-11-2010 at 10:56 AM.

  13. #13
    Registered User
    Join Date
    11-03-2009
    Location
    Ohio
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: Trying to use SUMIFS to sum a column based on two conditions

    I have been playing with the formula for about an hour and I am still stuck.

    Here is a link to the Google Spreadsheet I am testing this on.
    Google Spreadsheet

    I have worked through the formula all the way through a number of times and it looks like it should work. But I only get a 0.

    DonkeyOte mentioned that this formula would not work on pre 2007 excel, but I cannot figure out why?

    All help is appreciated.

  14. #14
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,706

    Re: Trying to use SUMIFS to sum a column based on two conditions

    OK I'm not an expert on Google docs but I seem to recall that SUMPRODUCT doesn't work very well on conditional counts/sums you probably need an "array formula". Try this

    =ArrayFormula(SUM(If((Data!C2:C100="Office2")*(Data!A2:A100<DATE(2010,1,14))*(Data!A2:A100>DATE(2010,1,1)),Data!D2:D100)))

    Note: I can't open your attachment, it's asking for a password....

  15. #15
    Registered User
    Join Date
    11-03-2009
    Location
    Ohio
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: Trying to use SUMIFS to sum a column based on two conditions

    Sorry about the link. Lets try this one, you shouldn't have to sign in with this link.

    Google Spreadsheet

    I am checking out the formula now.

    Thanks

+ 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