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

Prepping for a Fabric certification exam? Join us for a live prep session with exam experts to learn how to pass the exam. Register now.

Reply
Anduve11
Frequent Visitor

Calculate age as of a specified date

I'm trying to calculate the age as of an Event Date.  I have 2 tables, Table 1 - CustomerDate and Table 2 - EventData.  I'm trying to find the age of the participant at the time of event.  I tried to do a calculated column with a DATEDIFF function with the birthdate and eventdate, but because the data is in two different tables it's not letting me do that.

Screen Shot 2017-11-17 at 9.25.19 AM.png

 

Any advice on how to solve this would be greatly appreciated?

 

Thanks

1 ACCEPTED SOLUTION
Zubair_Muhammad
Community Champion
Community Champion

Hi  @Anduve11

 

Try this calculated column in Events table (Table 2)

 

Age=
DATEDIFF (
    LOOKUPVALUE ( Table1[Birthdate], Table1[Customer ID], Table2[CustomerID] ),
    Table2[EventDate],
    YEAR
)

View solution in original post

4 REPLIES 4
cfindling
Regular Visitor

Actually, nevermind, this function/column did not work.  It works if the birtdate happened in the year before the date of service, but if the birthdate was after it was still increasing the age when it shouldn't. 

pxg08680
Resolver III
Resolver III

@Anduve11

You can try this too. Join both the table on CustomerID. Then in First table create a calculated column

 

Column = DATEDIFF(Table3[BirthDate],RELATED(Table4[Eventdate]),YEAR)

 

Solution provided by @Zubair_Muhammad is more easier I think. But this works tooSmiley Happy

Zubair_Muhammad
Community Champion
Community Champion

Hi  @Anduve11

 

Try this calculated column in Events table (Table 2)

 

Age=
DATEDIFF (
    LOOKUPVALUE ( Table1[Birthdate], Table1[Customer ID], Table2[CustomerID] ),
    Table2[EventDate],
    YEAR
)

I had this same issue and the calculated column worked, but I have several blank lines where the age is not populating.  What would be causing blank lines?

Helpful resources

Announcements
PBIApril_Carousel

Power BI Monthly Update - April 2025

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

Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

April2025 Carousel

Fabric Community Update - April 2025

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