Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
pdoucette
Frequent Visitor

Under 18 at any point during a time Frame?

I'm trying to figure out a way to see if a person we served was, at any point, under the age of 18 during a given time frame....7/1/19 - 6/30/20.  Age would be calculated off of a Birthdate field. 

 

 

 

2 ACCEPTED SOLUTIONS
Regex
Regular Visitor

Please see full solution below.

 

Table1 contains two columns, with "Persons Name" and "Birthdate"

 

WasUnderage:=IF(COUNTROWS(Table1) <> 1, BLANK(), 

VAR DateOfBirth = VALUES(Table1[Birthdate])

VAR Date18 = DATE(YEAR(DateOfBirth)+18, MONTH(DateOfBirth), DAY(DateOfBirth))

VAR result = AND(DateOfBirth <= DATE(2020,30,6), Date18 > DATE(2019,7,1))

RETURN
result
)

 

View solution in original post

Hi,

 

There is a mistake in the order of one of the dates:

 

Try changing DATE(2020, 30, 6) to DATE(2020, 6, 30)

 

View solution in original post

4 REPLIES 4
Regex
Regular Visitor

Please see full solution below.

 

Table1 contains two columns, with "Persons Name" and "Birthdate"

 

WasUnderage:=IF(COUNTROWS(Table1) <> 1, BLANK(), 

VAR DateOfBirth = VALUES(Table1[Birthdate])

VAR Date18 = DATE(YEAR(DateOfBirth)+18, MONTH(DateOfBirth), DAY(DateOfBirth))

VAR result = AND(DateOfBirth <= DATE(2020,30,6), Date18 > DATE(2019,7,1))

RETURN
result
)

 

Thank You, I think this is close but I am returning all False values but feel I met the Result...I will keep playing with it

Hi,

 

There is a mistake in the order of one of the dates:

 

Try changing DATE(2020, 30, 6) to DATE(2020, 6, 30)

 

jthomson
Solution Sage
Solution Sage

Well you're only interested in the earliest part of the time frame - I don't know where that's coming from and it doesn't really matter, try something like:

 

18check = var earliesttimeframe = min(however you are defining your time frame)

var whenpersonis18 = dateadd([birthdate],18,year)

return if (earliesttime<whenpersonis18,"was under 18","wasn't under 18")

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.