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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
EmmaDilemma
New Member

How do I calculate the duration between two date in Years and months (not days) in Power Query

How do I calculate the duration between two dates in Years and/or months (not days) in Power Query   

I need to insert a column which will show the age of the customer when they purchased their product.  I have their date of birth and the transaction date - I need to report on the age of customer at transation date in Years.

Thanks in advance

1 ACCEPTED SOLUTION
Anonymous
Not applicable

I was being lazy and forgtot to round decimal places....

= Table.AddColumn(#"Changed Type", "Years", each Number.Round(Duration.Days([Purchase] - [Birth])/365,2), type number)

View solution in original post

4 REPLIES 4
EmmaDilemma
New Member

this is great James - I will give it a try now - Im assuming I go to powerquery - add column - custom column ?

 

Anonymous
Not applicable

Yea thats correct, let me know if you get stuck and I can add screenshots.

 

Thanks,

Anonymous
Not applicable

Hi,

 

 Give this a go (assumed coumns are called Birth and Purchase)

= Table.AddColumn(#"Changed Type", "Years", each Duration.Days([Purchase] - [Birth])/365, type number)

 

Thanks,

Anonymous
Not applicable

I was being lazy and forgtot to round decimal places....

= Table.AddColumn(#"Changed Type", "Years", each Number.Round(Duration.Days([Purchase] - [Birth])/365,2), type number)

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.