Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
8 years ago
Solved

DATADIFF not recognised

Hi there,   I am not able to get the DATEDIFF formula to work - it is not recognised by PowerBI.  Not sure why.  Any help would be much appreciated.   Thanks.
  • OwenAuger's avatar
    OwenAuger
    8 years ago

    Hi Anonymous

     

    Oh yep sure - the code from my previous post was intended to replace the entire step i.e. to be pasted in the Advanced Editor rather than the Custom Column dialog box.

     

    If you are entering code in the Custom Column dialog box, use this instead:

     

    let
       fnMonthIndex = each Date.Year(_)*12 + Date.Month(_),
       todayindex = fnMonthIndex( DateTime.Date(DateTime.FixedLocalNow()) )
    in
       todayindex - fnMonthIndex([Modified])