Reply
EmmaDilemma
New Member
Partially syndicated - Outbound

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

Syndicated - Outbound

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

Syndicated - Outbound

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

 

Syndicated - Outbound

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

 

Thanks,

JamesRobson
Resolver II
Resolver II

Syndicated - Outbound

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,

Syndicated - Outbound

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)

avatar user

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors (Last Month)
Top Kudoed Authors (Last Month)