'Formula to count number of people of a certain age range and gender

I have a column for age and a column for gender. How can I get the number of people with ages between 0-18 and with a gender of "male"?

For example, with the following data, the formula should return "1":

Name Age Gender
Rick 70 male
Morty 14 male
Summer 17 female
Beth 34 female
Jerry 35 male


Solution 1:[1]

Assuming your age data is in column A:A and gender in column B:B:

=COUNTIFS(A:A,"<=18",B:B,"M")

(and I hope all age values are >0). Otherwise:

=COUNTIFS(A:A,"<=18",A:A,">=0",B:B,"M")

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ttaaoossuuuu