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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Suhel_Ansari
Helper IV
Helper IV

power bi dax formula Get days, months, and years between dates

Hi DAX Expert,

I need the DAX formula to calcuate the Year , Months and Days between the 2 given dates as seen in the following screen print, however as seen I am not getting the required output, Please assist with the correct formula. Thanks

Suhel_Ansari_0-1660226008293.png

Regards

Suhel

1 ACCEPTED SOLUTION

@Suhel_Ansari , One of the way id have diff days and convert into month using 365 day and 30 days logic

 

new column =

var _diff = datediff([registration Date], [date of last known distance], day)

return

quotient(_diff , 365) & " Years " & quotient(mod(_diff , 365) ,30) & " Months "  & mod(mod(_diff , 365) ,30) 

View solution in original post

3 REPLIES 3
Suhel_Ansari
Helper IV
Helper IV

@amitchandak  , @v-yalanwu-msft  , @v-kelly-msft , please assit. Thanks

@Suhel_Ansari , One of the way id have diff days and convert into month using 365 day and 30 days logic

 

new column =

var _diff = datediff([registration Date], [date of last known distance], day)

return

quotient(_diff , 365) & " Years " & quotient(mod(_diff , 365) ,30) & " Months "  & mod(mod(_diff , 365) ,30) 

@amitchandak  , It partially working The year and Month are correct however Days are calcualting wrong as shown in  attached screen print. Thanks

Suhel_Ansari_0-1660294038643.png

 

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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