Forum Discussion
Unable to format year column as date
- 2 years ago
let
Source = Excel.Workbook(File.Contents("C:\Users\mbhet\OneDrive\Documents\#MichaelHetheringtonConsulting\Tech\Power BI\Microsoft Power BI Data Analyst\Data\AdventureWorksData.xlsx"), null, true),
Date_Sheet = Source{[Item="Date",Kind="Sheet"]}[Data],
#"Promoted Headers" = Table.PromoteHeaders(Date_Sheet, [PromoteAllScalars=true]),
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Year", Int64.Type}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Year1", each #date([Year],1,1),type date)
in
#"Added Custom"
Thanks for the prompt reply. I'm not understanding where to enter that. I'm attempting to use that code to generate a new column, then the old column could be deleted?
Using the new column selection, Year1 = #date([Year],1,1) returns an error message
The following syntax error occurred during parsing: Invalid token, Line 1, Offset 2, #