Forum Discussion
Sheref_Morad
4 years agoFrequent Visitor
Date Column
I have a column in Power Query that has a several years period as a Whole Number, I want to transfer it to a date column
- Anonymous4 years ago
Hi Sheref_Morad ,
First, change the data type of Year Column to Text.
And now , again change the data type to Date, it'll work.
#"Changed Type1" = Table.TransformColumnTypes(#"Replaced Value",{{"Year", type text}}), #"Changed Type2" = Table.TransformColumnTypes(#"Changed Type1",{{"Year", type date}})
PC2790
4 years agoCommunity Champion
Step 1: Convert to date normally, power query code as below:
= Table.TransformColumnTypes(Table,{{"Year", type date}})
Step 2: From Transform --> Date & Time Column --> Select Date -- Year as shown below:
Code as below:
= Table.TransformColumns(#"Changed Type",{{"Year", Date.Year, Int64.Type}})
However it will convert the year as Whole number only as this is Power BI interprets the year but it should not hamper any of your reporting and calculations
Sheref_Morad
4 years agoFrequent Visitor
Thank you for Answering , it converted into irrelvant Date so i can't make the year data that was given in the source data