Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

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

  • Anonymous 

    Add a custom column with the following code then change Data TYpe to Date

    =try Date.From( [EndPricingPeriod] & "01" ) otherwise [EndPricingPeriod]

     



    • Anonymous's avatar
      Anonymous
      Not applicable

      Nice and easy solution! Thank you!