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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
homeshagarwal
Regular Visitor

Calculating Customer Age at the time of Transaction

Hi all!

Need help with a DAX code to create a calculation to find out the Customer's Age at the date of the transaction and not as per TODAY. The following is my data model:

homeshagarwal_0-1687492839316.png

My Customer Table and Sales Table are connected based on Customer ID and not on a Date Field.

Could you please help me out here?

2 ACCEPTED SOLUTIONS

@homeshagarwal 

Please try

Customer Age =
DATEDIFF (
    RELATED ( 'Customer Lookup'[Date of Birth] ),
    'Sales by Store'[Transaction Date],
    YEAR
)

View solution in original post

devanshi
Helper V
Helper V

Age = DATEDIFF('Table'[Birthdate], 'Table'[Transaction Date],YEAR)

View solution in original post

5 REPLIES 5
homeshagarwal
Regular Visitor

Thanks, @tamerj1 !🙌
This was pretty straightforward. Do you know where I messed up?
For some reason, I was trying to add a new column in the Customer's table with this formula earlier 😅😂 so wasn't getting it.

devanshi
Helper V
Helper V

Age = DATEDIFF('Table'[Birthdate], 'Table'[Transaction Date],YEAR)

tamerj1
Super User
Super User

Hi @homeshagarwal 
So are looking for a calculated column in the Sales table or a measure in report sliced by transaction? Do you have date of birth column for each customer or just the current age of the customer in years?

Hi @tamerj1 
I'm looking to include a Calculated Column in my Sales table to specify the customers' age at the time of the transaction. Also, yes, I do have a Birthdate column in the Customer's table.

@homeshagarwal 

Please try

Customer Age =
DATEDIFF (
    RELATED ( 'Customer Lookup'[Date of Birth] ),
    'Sales by Store'[Transaction Date],
    YEAR
)

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.