Forum Discussion
Anonymous
5 years agoNot applicable
MCode Date Syntax - Error Message
I'm getting an error, but I dont know how to fix it. The error is coming from the "IfStatement" row. Error:Expression.Error: The name 'DateTime.Month' wasn't recognized. Make sure it's spelled corre...
- Anonymous5 years ago
I ended up breaking this out into several lines in order to simplify what I'm trying to get to.
This is what worked:
#"Added Custom" = Table.AddColumn(#"Changed Type", "Current Month Number", each Date.Month(DateTime.LocalNow())), #"Added Custom1" = Table.AddColumn(#"Added Custom", "Current Year", each #date(Date.Year(DateTime.LocalNow()), 8, 1)), #"Added Custom2" = Table.AddColumn(#"Added Custom1", "Prior Year", each #date(Date.Year(DateTime.LocalNow())-1, 8, 1)), #"Added Conditional Column" = Table.AddColumn(#"Added Custom2", "FilterDate", each if [Current Month Number] >= 8 then [Current Year] else [Prior Year]), #"Filtered Rows" = Table.SelectRows(#"Added Conditional Column", each [Date1] >= [FilterDate]) in #"Filtered Rows"
amitchandak
5 years agoSuper User
Anonymous , Actually Date has Month and year, Not datetime.
example
Date.Month(DateTime.Date(DateTime.LocalNow()))
correct others