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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Return number of years and months from number of days

Hi!

 

I have a measure that calculates number of days between two dates. 

 

I'm trying to figure out a new measure that returns the number of years and months based on the number of days. 

 

Ex: If the number of days measure is 400, the number of years and months should return "1 year & 1 month".

 

Thanks! 

 

 

2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

Hi, 

 

You can try the below formula:

 

Year&Month = if( [Datedifference]<365, "Less than 1 year", INT([Datedifference]/365)  & " years & " & ([Datedifference] - INT([Datedifference]/365)*365)/30 & "months")

 

The years will be shown without decimals, the months will have decimals, you can format those as well.

 

Regards,

IOana

View solution in original post

Anonymous
Not applicable


@Anonymous wrote:

Hi, 

 

You can try the below formula:

 

Year&Month = if( [Datedifference]<365, "Less than 1 year", INT([Datedifference]/365)  & " years & " & ([Datedifference] - INT([Datedifference]/365)*365)/30 & "months")

 

The years will be shown without decimals, the months will have decimals, you can format those as well.

 

Regards,

IOana


 

 

Great! I did some changes that worked out fine: 

 

IF([Daysbetweenmeasure]<365;
   INT([Daysbetweenmeasure]/30) &" months";
   INT([Daysbetweenmeasure]/365) &" years & " & 
      FIXED(VALUE( ([Daysbetweenmeasure]- 
      INT([Daysbetweenmeasure]/365) *365) /30);
      0) & " months")

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi, 

 

You can try the below formula:

 

Year&Month = if( [Datedifference]<365, "Less than 1 year", INT([Datedifference]/365)  & " years & " & ([Datedifference] - INT([Datedifference]/365)*365)/30 & "months")

 

The years will be shown without decimals, the months will have decimals, you can format those as well.

 

Regards,

IOana

Anonymous
Not applicable


@Anonymous wrote:

Hi, 

 

You can try the below formula:

 

Year&Month = if( [Datedifference]<365, "Less than 1 year", INT([Datedifference]/365)  & " years & " & ([Datedifference] - INT([Datedifference]/365)*365)/30 & "months")

 

The years will be shown without decimals, the months will have decimals, you can format those as well.

 

Regards,

IOana


 

 

Great! I did some changes that worked out fine: 

 

IF([Daysbetweenmeasure]<365;
   INT([Daysbetweenmeasure]/30) &" months";
   INT([Daysbetweenmeasure]/365) &" years & " & 
      FIXED(VALUE( ([Daysbetweenmeasure]- 
      INT([Daysbetweenmeasure]/365) *365) /30);
      0) & " months")

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.