Forum Discussion

CRyley's avatar
CRyley
New Member
3 years ago
Solved

Using Today's date for aging calculation in custom column

Hi,   I'm a complete newbie to this community and Power Query in general.   I'm trying to calculate aging (difference between today's date and one of two date field columns, as follows. If there ...
  • CRyley's avatar
    CRyley
    3 years ago

    I was able to figure this out on my own. I did a bit more research on using M and also discovered the Add Conditional Column feature, which got me started on the if then else statement.

     

    #"Added Conditional Column" = Table.AddColumn(#"Reordered Columns2", "Aging", each if [Revised Implementation Date] = null then Duration.Days(today-[Original Estimated Implementation Date]) else Duration.Days(today-[Revised Implementation Date]))

     

    Thanks for getting me started along this path m_dekorte

     

    Cheers

  • m_dekorte's avatar
    m_dekorte
    3 years ago

    Hi CRyley 

     

    Great you found a solution on your own!

    With the error message I could identify the problem with the code above you were missing a set of parenthesis. That needed to be wrapped around Date.From and the end of the expression, like below.

     

    Duration.Days( today - ( Date.From( [Revised Implementation Date] ) ?? [Original Estimated Implementation Date]  ))