Forum Discussion

ALI1265's avatar
ALI1265
Regular Visitor
1 year ago
Solved

Date difference calculation using if and today functions when end date is unknown

I'm trying to calculate difference between start and end date. For cases where the end date is blank I want to use the TODAY() function to calculate the number of days between the start date and today's date.

Does anyone know why I'm getting an error when using the formula below?


= Table.AddColumn(#"Renamed Columns", "duration", each if [ENDDATE] = null then TODAY()-[STARTDATE] else [ENDDATE]-[STARTDATE])


Power BI error message: "The name 'TODAY' wasn't recognised. Make sure it's spelled correctly."

 

Thanks!

  • ALI1265 

     

    use DateTime.LocalNow() insted of today()!

     

    If this post helps, then I would appreciate a thumbs up and mark it as the solution to help the other members find it more quickly. 

     

3 Replies