Forum Discussion

Garbo62's avatar
Garbo62
Resolver I
3 years ago
Solved

DAX DATEDIFF

I'm looking for a DAX query to return the difference between to dates in the format of x Years & y months I have the following that nearby works   Years = DATEDIFF(cr6fb_gpe_a_aset[AAsetProcDate],...
  • Ritaf1983's avatar
    3 years ago

    Hi Garbo62 
    Try to use this formula
    YearMonths =
    VAR Years = DDATEDIFF(cr6fb_gpe_a_aset[AAsetProcDate], TODAY(), YEAR)
    VAR Months = DATEDIFF(cr6fb_gpe_a_aset[AAsetProcDate], Today(),MONTH) - Years * 12
    RETURN CONCATENATE(CONCATENATE(CONCATENATE(Years," Years, "),Months)," Months")

    If this post helps, then please consider Accepting it as the solution to help the other members find it more quickl

  • Garbo62's avatar
    3 years ago

    Hi, Solved it

    Age = INT(DATEDIFF(cr6fb_gpe_a_aset[AAsetProcDate], TODAY(), MONTH)/12) & " Years & " & DATEDIFF(cr6fb_gpe_a_aset[AAsetProcDate], TODAY(), MONTH) - INT(DATEDIFF(cr6fb_gpe_a_aset[AAsetProcDate], TODAY(), MONTH)/12)*12 & " Months"