+ Reply to Thread
Results 1 to 6 of 6

Thread: Help for COUNTIF Function

  1. #1
    Registered User
    Join Date
    06-26-2011
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    11

    Help for COUNTIF Function

    Hello all

    I am trying to workout number of students in age range group like 20-30, 30-40 and 40-50 based on a column "Student dob" . Can any one help your help and advice highly appreciated.

  2. #2
    Forum Guru Colin Legg's Avatar
    Join Date
    03-30-2008
    Location
    UK
    MS-Off Ver
    2003, 2007 and 2010
    Posts
    1,207

    Re: Help for COUNTIF Function

    Hello,

    Perhaps you could amend your thread title to something which does not assume what the solution will be?


    Add a helper column to calculate the age of each student, eg.
    =DATEDIF($B4,$A$1,"y")
    where B4 contains the DOB and A1 contains today's date.

    Then add a pivot table, add the age column to the row labels and group by every 10 years. Then add the age column to the values field and set the aggregator to Count.
    Attached Files Attached Files
    Hope that helps,

    Colin

    RAD Excel Blog

    Other tutorials:
    Array Formulas | Deleting Rows with VBA

  3. #3
    Registered User
    Join Date
    06-26-2011
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Help for COUNTIF Function

    Hello Colin,

    Thank you very much for your reply. Is there way I can get the required result without adding the column and pivot table. I mean I can use DATEDIF in conjunction with something COUNT or COUNTIF function. Your help will be highly appreciated.

    Kaka

  4. #4
    Forum Guru Colin Legg's Avatar
    Join Date
    03-30-2008
    Location
    UK
    MS-Off Ver
    2003, 2007 and 2010
    Posts
    1,207

    Re: Help for COUNTIF Function

    Hi Kaka,

    Not a good way, no - and you can't do it with COUNTIF unless you use a helper column. If you don't want to use a helper column, you would have to use a SUMPRODUCT formula which is expensive. I've attached the previous workbook to show you how.

    =SUMPRODUCT(
        --(DATEDIF($B$4:$B$32,$A$1,"y")>=$K3),
        --(DATEDIF($B$4:$B$32,$A$1,"y")<=$L3))
    Attached Files Attached Files
    Hope that helps,

    Colin

    RAD Excel Blog

    Other tutorials:
    Array Formulas | Deleting Rows with VBA

  5. #5
    Registered User
    Join Date
    05-04-2009
    Location
    ME
    MS-Off Ver
    Excel 2003,2007
    Posts
    74

    Re: Help for COUNTIF Function

    Also,

    =SUMPRODUCT(($C$4:$C$32>=K3)*($C$4:$C$32<=L3))

  6. #6
    Forum Guru Colin Legg's Avatar
    Join Date
    03-30-2008
    Location
    UK
    MS-Off Ver
    2003, 2007 and 2010
    Posts
    1,207

    Re: Help for COUNTIF Function

    Quote Originally Posted by nawas View Post
    Also,

    =SUMPRODUCT(($C$4:$C$32>=K3)*($C$4:$C$32<=L3))
    Yes, but column C is a helper column for the pivot table.
    Hope that helps,

    Colin

    RAD Excel Blog

    Other tutorials:
    Array Formulas | Deleting Rows with VBA

+ 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.2.0