+ Reply to Thread
Results 1 to 10 of 10

Countif multiple conditions

Hybrid View

  1. #1
    Registered User
    Join Date
    11-16-2008
    Location
    Spain
    Posts
    5

    Countif multiple conditions

    Hi.

    I have a table like this:

    Name (A).....Date-in (B)....Date-out (C)
    Name1........27/12/2008....3/01/2009
    Name2........25/11/2008....28/11/2008
    ...

    I want to count the rows (in the entire table) that B and C dates intersect with a reference dates (say J1 and J2).

    It is a booking table so I want to know if the apartment is available for the reference dates (i.e. no bookings for that days).

    I tried first a simple double conditional to know if a date is inside two dates but it didn't work:
    =SUMPRODUCT(--(B:B<J1),--(C:C>J1))

    Regards.
    Last edited by Carlos_82; 11-16-2008 at 08:48 AM.

  2. #2
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326
    Hi and welcome to the board
    Sumproduct does not work with entire columns like b:b
    You must define the range as for example b1:b65535
    Check this page for a detailed explanation

  3. #3
    Registered User
    Join Date
    11-16-2008
    Location
    Spain
    Posts
    5
    i tried changing B:B by B1:B100 and it is the same.

    Thanks.

  4. #4
    Registered User
    Join Date
    11-16-2008
    Location
    Spain
    Posts
    5
    I tried changing B:B by B1:B100 and it is the same.

    Thanks.

  5. #5
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326
    Could you post a sample of your data ( you of course should change both ranges and they need to be the same length)

  6. #6
    Registered User
    Join Date
    11-16-2008
    Location
    Spain
    Posts
    5
    It worked in Excel with B:B (and C:C).

    The problem is that I can't get it to work on Google Spreadsheets.


    The "--" operator doesn't seem to exist in Calc (it is based in Openoffice Calc), so I tried this:
    =SUMPRODUCT(IF((B:B<J14);1;0);IF((C:C>J14);1;0))

    But the result is 0 when it should be 1, 2, ...

    Thanks.

  7. #7
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492
    Your original post, you said column A needed to check for an intersect in J1 and J2, but your formulas are strictly checking J1. What happened to J2?

    And it's not a single day you're checking, aren't you saying that the dates entered in J1:J2 represent a date range and you're comparing that entire date range against all the date ranges in B:C to see if there are any scheduling conflicts? So in J3 you'd want a result like ("Available", "Not Available").
    _________________
    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!)

  8. #8
    Registered User
    Join Date
    11-16-2008
    Location
    Spain
    Posts
    5
    Quote Originally Posted by JBeaucaire View Post
    Your original post, you said column A needed to check for an intersect in J1 and J2, but your formulas are strictly checking J1. What happened to J2?

    And it's not a single day you're checking, aren't you saying that the dates entered in J1:J2 represent a date range and you're comparing that entire date range against all the date ranges in B:C to see if there are any scheduling conflicts? So in J3 you'd want a result like ("Available", "Not Available").
    Yes, the formula was only to test function. I don't have any problem with the formula.

    What I want to do is to get it working on Openoffice Calc.

    Thanks.

    Quote Originally Posted by tigertiger View Post
    you try this formula

    PHP Code: 
    =SUMPRODUCT(--(B2:B50>=J1),--(C2:C50<=J2)) 
    That formula works on Excel but not in Openoffice Calc.

    Any idea?

  9. #9
    Valued Forum Contributor
    Join Date
    11-11-2008
    Location
    Euro
    MS-Off Ver
    2007, 2010
    Posts
    470
    Quote Originally Posted by Carlos_82 View Post
    Hi.

    I have a table like this:

    Name (A).....Date-in (B)....Date-out (C)
    Name1........27/12/2008....3/01/2009
    Name2........25/11/2008....28/11/2008
    ...

    I want to count the rows (in the entire table) that B and C dates intersect with a reference dates (say J1 and J2).

    It is a booking table so I want to know if the apartment is available for the reference dates (i.e. no bookings for that days).

    I tried first a simple double conditional to know if a date is inside two dates but it didn't work:
    =SUMPRODUCT(--(B:B<J1),--(C:C>J1))

    Regards.
    you try this formula

    PHP Code: 
    =SUMPRODUCT(--(B2:B50>=J1),--(C2:C50<=J2)) 

  10. #10
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326
    Carlos, this is an XL forum, not a Google spreadsheet nor an openoffice forum.
    Please search for a forum for those applications
    If you go on changing what you want to do every post and it has nothing to do with XL, I will have to close this thread.

+ 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