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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

Top Solution Authors