Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.
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:
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?
Solved! Go to Solution.
Please try
Customer Age =
DATEDIFF (
RELATED ( 'Customer Lookup'[Date of Birth] ),
'Sales by Store'[Transaction Date],
YEAR
)
Age = DATEDIFF('Table'[Birthdate], 'Table'[Transaction Date],YEAR)
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.
Age = DATEDIFF('Table'[Birthdate], 'Table'[Transaction Date],YEAR)
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.
Please try
Customer Age =
DATEDIFF (
RELATED ( 'Customer Lookup'[Date of Birth] ),
'Sales by Store'[Transaction Date],
YEAR
)