Forum Discussion
Anonymous
5 years agoNot applicable
Format a column from text to date
Hi all,
I like to change the format of a column to date with the following values:
EndPricingPeriod
| May 2021 |
| 202108 |
| 202107 |
| 202107 |
| 202108 |
| May 2021 |
| May 2021 |
| May 2021 |
| July2021 |
| July 2021 |
| July2021 |
| July 2021 |
| July 2021 |
| July 2021 |
| July 2021 |
| July2021 |
| July 2021 |
| July 2021 |
| July 2021 |
| July2021 |
| July 2021 |
| July 2021 |
| July 2021 |
| July 2021 |
| July 2021 |
| July 2021 |
| 202108 |
| 202107 |
| 202107 |
| July 2021 |
As you can see there are two formats of the dates.
When I try to convert the values I get an error on the ones that look like '202107':
DataFormat.Error: We couldn't parse the input provided as a Date value.
I'd like to format these values to date type in Power Query as well.
Does anyone know how to do this?
Thanks!
Anonymous
Add a custom column with the following code then change Data TYpe to Date=try Date.From( [EndPricingPeriod] & "01" ) otherwise [EndPricingPeriod]
2 Replies
- FowmySuper User
Anonymous
Add a custom column with the following code then change Data TYpe to Date=try Date.From( [EndPricingPeriod] & "01" ) otherwise [EndPricingPeriod]- AnonymousNot applicable
Nice and easy solution! Thank you!