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!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
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!
Solved! Go to Solution.
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 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")
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 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")
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 38 | |
| 38 | |
| 36 | |
| 28 | |
| 28 |
| User | Count |
|---|---|
| 124 | |
| 89 | |
| 73 | |
| 66 | |
| 65 |