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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
)

Regards
Zubair

Please try my custom visuals

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
)

Regards
Zubair

Please try my custom visuals

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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