Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not 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!

1 ACCEPTED SOLUTION
Fowmy
Super User
Super User

@Anonymous 

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

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

 



Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

2 REPLIES 2
Fowmy
Super User
Super User

@Anonymous 

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

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

 



Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Anonymous
Not applicable

Nice and easy solution! Thank you!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors