Stumped on how to count people in group 1 with age 4y 0m or more but less than 18y 0m.
(4x8 worksheet attached with dates in format dd/mm/yy)
Last edited by 13sydwest; 08-29-2011 at 06:24 AM.
Can you use a helper cell...
Add a column D for just the year
In column D...D2 copied down =DATEDIF(B2,A2,"Y")
=COUNTIFS($E$2:$E$7,1,$D$2:$D$7,">=4",$D$2:$D$7,"<=18")
HTH
Regards, Jeff
If you like the answer(s) provided, why not add some reputation by clicking the * below
Please use [ Code ] tags when posting [ /Code ]
Please view/read the Forum rules --- How to mark a thread as solved
Thanks Jeff. Problem is that the helper cell (if I've understood it correctly) returns any age between 18y 0m and 18y 11m as "18".
Say I want no. in group with age equal to or greater than 4 but less than or equal to 18.
I've added a highlighted row to the worksheet where age of person is 18y 4m. Helper cell then shows this as 18. The COUNTIFS function includes this person in the age range requested and so returns an incorrect count.
I guess I could get the helper cell to return age in months, or even better, in weeks to get a more accurate, yet possibly still incorrect, count.
Syd
From your first sample spreadsheet, and without a helper column, you can use SUMPRODUCT like this:
or COUNTIFS like this:=SUMPRODUCT(--(D2:D8=1),--(A2:A8>=DATE(YEAR(B2:B8)+4,MONTH(B2:B8),DAY(B2:B8))),--(A2:A8<DATE(YEAR(B2:B8)+18,MONTH(B2:B8),DAY(B2:B8))))
but the COUNTIFS will require Ctrl-Shift-Enter.=COUNTIFS(D2:D8,1,A2:A8,">="&DATE(YEAR(B2:B8)+4,MONTH(B2:B8),DAY(B2:B8)),A2:A8,"<"&DATE(YEAR(B2:B8)+18,MONTH(B2:B8),DAY(B2:B8)))
Last edited by ConneXionLost; 08-28-2011 at 02:46 AM.
“To sin by silence when they should protest makes cowards of men.” ~ Abraham Lincoln
Many thanks. The SUMPRODUCT will be perfect for me.
I tried the COUNTIFS (with the CTRL+SHIFT+ENTER) but could only get it to return "0" instead of 2. Not sure how I've applied it wrongly.
Syd
change the helper cell to give months
=DATEDIF(B2,A2,"m")
then its simply
=SUMPRODUCT(--(D2:D9>=16),--(D2:D9<216),--(E2:E9=1))
"Unless otherwise stated all my comments are directed at OP"
Mojito connoisseur and a dabbler in Cisco
where does code go ?
look here
how to insert code
how to enter array formula
why use -- in sumproduct
recommended reading
wiki Mojito
how to say no convincingly
most important thing you need
Martin Wilson: SPV
and RSMBC
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks