cancel
Showing results 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

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.

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

Thanks

1 ACCEPTED SOLUTION
Community Champion

Try this calculated column in Events table (Table 2)

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

Regards
Zubair

4 REPLIES 4
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.

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 too

Community Champion

Try this calculated column in Events table (Table 2)

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

Regards
Zubair

Regular Visitor

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?

Announcements

#### 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 Monthly Update - June 2024

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

#### 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
Top Kudoed Authors