Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreThe FabCon + SQLCon recap series starts April 14th at 8am Pacific. If you’re tracking where AI is going inside Fabric, this first session is a can't miss. Register now
I am tyring to add the column as follows
= Table.AddColumn(#"Added Custom", "OrderAge", each DATEDIFF ([DateTimeCreated],TODAY(),DAY))
But I get the meaasge
Expression.Error: The name 'DATEDIFF' wasn't recognized. Make sure it's spelled correctly.
Can you help as I cannot see what I have done wrong?
Solved! Go to Solution.
@DBATTIN I guess you have DateTimeCreated field as DateTime datatype which also needs to converted into Date type. So please try this...
Duration.Days(Duration.From(DateTime.Date(DateTime.LocalNow())-DateTime.Date([DateTimeCreated])))
Proud to be a PBI Community Champion
@DBATTIN You are trying to use both M-Language and DAX at one place and that's the reason for error. DATEDIFF is available in DAX but not in Power Query Editor.
If you want to achieve DATEDIFF in Power Query Editor then use Duration.Days(Duration.From([EndDate]-[StartDate])))
Proud to be a PBI Community Champion
@PattemManoharIt now will not recognise the funtion Today() is that for the same reason? If so what function do I need to use for Today please?
@DBATTIN Please use DateTime.Date(DateTime.LocalNow())
Proud to be a PBI Community Champion
@PattemManoharthe formula is now
OrderAge = Duration.Days(Duration.From(DateTime.Date(DateTime.LocalNow())-[DateTimeCreated]))
This is now showing no syntax errors but returns an error value in the custom column. Have I done something wrong?
@DBATTIN I guess you have DateTimeCreated field as DateTime datatype which also needs to converted into Date type. So please try this...
Duration.Days(Duration.From(DateTime.Date(DateTime.LocalNow())-DateTime.Date([DateTimeCreated])))
Proud to be a PBI Community Champion
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 53 | |
| 40 | |
| 38 | |
| 19 | |
| 18 |
| User | Count |
|---|---|
| 70 | |
| 69 | |
| 34 | |
| 33 | |
| 30 |