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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
ktt777
Helper V
Helper V

Calulate Age

Hi Everyone

I have below table and i want to use DAX formula to calculate the age of people. 

NameDOB 
A10/2/1988
B2/5/1990
C0
D 

 

but for DOB data is Blank or "0", i want to display as "No Data" 

 

is there a way to do so ? i try below code : 

 

Age = if ( Sheet2[DOB ]=""||Sheet2[DOB ]="0","No data", DATEDIFF(Sheet2[DOB ],TODAY(),YEAR))

 

but it said "DAX comparison operations do not support comparing values of type Date with values of type Text. Consider using the VALUE or FORMAT function to convert one of the values."

 

How can i create a Age group formula to categorize 0-18, 18-35, 35-60, over 60 and "No data" group?

 

thanks . 

2 ACCEPTED SOLUTIONS
harshnathani
Community Champion
Community Champion

@ktt777 ,

 

Convert the Data Type to Date/Time.

 

Use a Calculated Column

 

Age =
IF (NOT(ISBLANK('Table'[DOB ])),
FORMAT(DATEDIFF('Table'[DOB ],Today(),YEAR),"##"),"No Data")
 
1.jpg2.JPG
 
Regards,
Harsh Nathani
Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

View solution in original post

Hi @ktt777 ,

 

 

Create another calculated column.

 

Age Group =
IF('Table'[Age] <> "No Data",
SWITCH(
True(),

VALUE('Table'[Age]) > 60 , "Above 60",
VALUE('Table'[Age]) <=60 && VALUE('Table'[Age]) >30, "31-60",
VALUE('Table'[Age])<=30 && VALUE('Table'[Age]) >18 ,"19-30",
VALUE( 'Table'[Age]) <=18 , "Below 18"
),
"No Data")
 
 
4.JPG
 
 

Regards,
Harsh Nathani

Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

View solution in original post

3 REPLIES 3
harshnathani
Community Champion
Community Champion

@ktt777 ,

 

Convert the Data Type to Date/Time.

 

Use a Calculated Column

 

Age =
IF (NOT(ISBLANK('Table'[DOB ])),
FORMAT(DATEDIFF('Table'[DOB ],Today(),YEAR),"##"),"No Data")
 
1.jpg2.JPG
 
Regards,
Harsh Nathani
Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

Hi @ktt777 ,

 

 

Create another calculated column.

 

Age Group =
IF('Table'[Age] <> "No Data",
SWITCH(
True(),

VALUE('Table'[Age]) > 60 , "Above 60",
VALUE('Table'[Age]) <=60 && VALUE('Table'[Age]) >30, "31-60",
VALUE('Table'[Age])<=30 && VALUE('Table'[Age]) >18 ,"19-30",
VALUE( 'Table'[Age]) <=18 , "Below 18"
),
"No Data")
 
 
4.JPG
 
 

Regards,
Harsh Nathani

Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

Wonderful. 

 

thanks a lot 🙂

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.