Using Function in Criteria Range of DCOUNT

cfcaec

New Member
Joined
Feb 21, 2013
Messages
6
Hi

This is my first post, so please bear with me. I've gone through all the microsoft support pages etc... etc.. No luck.

I have created a register that gives the ages of the participants being registered. I need to figure out the number of boys and girls of different age groups. I used the formula =DCOUNT(database,column no,criteria) with criteria having two columns, Gender & Date of Birth. Under Gender was M, Under Date of Birth was >=01/03/2002 [dd/mm/yyyy]. This gave perfect results shwing me the number of boys less than 12 years old. However, wishing to make the formula dynamic I changed it to >=EDATE(TODAY(),-144) which is exactly twelve years ago. This formula gives wrong results and I can't understand why.

Can any one help me?

Thank you.

Tony
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
I forgot to mention that I use Excel 2007 on Window 7 Home Basic. Also the formula =EDATE(TODAY(),-144) evaluates perfectly elsewhere.
Thanks
Tony
 
Upvote 0
ABCD
1GENDERDATE OF BIRTHGENDERDATE OF BIRTH
2M>=EDATE(TODAY(),-144)F>=EDATE(TODAY(),-144)
3GENDERDATE OF BIRTH
4F16/05/1986
5M12/02/2006
6M15/04/2007
7F15/04/2007="G < 12: "&DCOUNT(A3:B8,2,$C$1:$D$2)
8M01/04/1984="B < 12: "&DCOUNT(A3:B8,2,$A$1:$B$2)

<tbody>
</tbody>

I will try and reproduce it here as all my attempts at copying and pasting have failed.

The answer in C7 & C8 come out wrong.

Thanks for all the help.

Tony
 
Upvote 0
ABCD
1GENDERDATE OF BIRTHGENDERDATE OF BIRTH
2M>=EDATE(TODAY(),-144)F>=EDATE(TODAY(),-144)
3GENDERDATE OF BIRTH
4F16/05/1986
5M12/02/2006
6M15/04/2007
7F15/04/2007="G < 12: "&DCOUNT(A3:B8,2,$C$1:$D$2)
8M01/04/1984="B < 12: "&DCOUNT(A3:B8,2,$A$1:$B$2)

<tbody>
</tbody>


I will try and reproduce it here as all my attempts at copying and pasting have failed.

The answer in C7 & C8 come out wrong.

Thanks for all the help.

Tony

Just for the sale of completeness: What are the expected outcomes (answers) in C7 and C8?

3/1/2002
GENDERDATE OF BIRTHGENDER
=M>=37316=F
GENDERDATE OF BIRTH
F5/16/1986
M2/12/2006
M4/15/2007
F4/15/2007G < 12: 2
M4/1/1984B < 12: 1

<tbody>
</tbody>

A1:

=EDATE(TODAY(),-144)

A3:

="=M"

B3:

=">="&$A$1

C3:

="=F"

C8: (Involves gender M)

="G < 12: "&DCOUNTA($A$4:$B$9,"GENDER",$A$2:$B$3)

C9: (involves gender F)

="B < 12: "&DCOUNTA($A$4:$B$9,"GENDER",$B$2:$C$3)

By the way, what are G's and B's?
 
Upvote 0
Thanks everyone. Solved it.

I wanted the table to be dynamic. That is as the months go by the table will keep updating the number of G (girls) and B (boys) of different age groups. The actual database keeps informing me of the number of girls and boys in different age categories (below 12, 12 to 16, 16 to 19, 19 to 21, 21 and above) as on date the file is opened. The example given just identifies the girls and boys below 12. So C7 should show G < 12: 1 (1 girl below 12) and C8 should show B < 12: 2 (2 boys below 12).

The only way to do that is to use EDATE(start date, months). Somehow using EDATE in the criteria row does not work. If I put the actual dates it works. However, that means I have to update the formula each time I open the file, say after 1 year.

Thanks to your inputs I tried putting =">="&EDATE(TODAY(),-144) in C3 and it worked like a charm.

Haven't figured out why >=01/03/2002 works, but >=EDATE(TODAY(),-144) does not but =">="&EDATE(TODAY(),-144) works!

Thanks all the same. Can sleep peacefully tonight.

Good night and God bless.

Tony
 
Upvote 0
You can try this too:

Code:
=">="&TEXT(EDATE(TODAY(),-144),"dd/mm/yyyy")

Result

GENDERDATE OF BIRTHGENDERDATE OF BIRTH
M>=01/03/2002F>=01/03/2002
GENDERDATE OF BIRTH
F16/05/1986
M12/02/2006
M15/04/2007
F15/04/2007B < 12: 2
M01/04/1984G < 12: 1
*******************************************

<tbody>
</tbody>

Markmzz
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,789
Messages
6,121,590
Members
449,039
Latest member
Arbind kumar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top