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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Date format from text

I have a column that's coming in as text that supposed to be a date. I want to convert that text to date but when I use Format(Date,"##/##/##") and then go to change it type it says format() is not able to convert text to date.

 

Example: 81015 = 8/10/15:

image.png

1 ACCEPTED SOLUTION
az38
Community Champion
Community Champion

@Anonymous 

yes.

try

Column = 
IF(ISBLANK([DATE]), BLANK(),
DATE(VALUE(RIGHT([DATE], 2)) + 2000, VALUE(LEFT([DATE], LEN([DATE])-4)), VALUE(MID([DATE],LEN([DATE])-3,2)))
)

do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

View solution in original post

10 REPLIES 10
mahoneypat
Microsoft Employee
Microsoft Employee

You can parse this out with DAX text functions, but this is a great application of Column from Examples in the power query editor.  Please see this link - https://docs.microsoft.com/en-us/power-bi/create-reports/desktop-add-column-from-example

 

I used it on similar data and it automatically created a custom column with this M expression

Text.Combine({Text.Reverse(Text.Middle(Text.Reverse(Text.From([Date], "en-US")), 4)), "/", Text.Reverse(Text.Middle(Text.Reverse(Text.From([Date], "en-US")), 2, 2)), "/20", Text.End(Text.From([Date], "en-US")

 

If you still want to do it with DAX, here is one way to do it

NewDateColumn = Left('Date'[Date],LEN('Date'[Date])-4)&"/"&Left(Right('Date'[Date],4),2)&"/"&RIGHT('Date'[Date],2)

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Anonymous
Not applicable

Thanks @mahoneypat  for the insightful information! 

 

When I tried to use the DAX statement I get this error.

 

image.png

az38
Community Champion
Community Champion

@Anonymous 

create a calculated column

Column = DATE(VALUE(RIGHT([DATE], 2)) + 2000, VALUE(LEFT([DATE], LEN([DATE])-4)), VALUE(MID([DATE],LEN([DATE])-3,2)))

do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn
Anonymous
Not applicable

@az38  Thanks for the information but I get "An argument of function 'LEFT' has the wrong data type or has an invalid value/" error.

az38
Community Champion
Community Champion

@Anonymous 

are you sure you copied the statement example as I suggested? it works as appropriated for me, I checked twice


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn
Anonymous
Not applicable

@az38

Yes , I've checked that I copied correctly.

 

image.png

az38
Community Champion
Community Champion

@Anonymous 

do you have values with 4 digit length?


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn
Anonymous
Not applicable

@az38 

The largest I have is 6 digit and the smallest I have is 5 digits. I went through my data set and it looks like I might have some blanks if that would affect it?

az38
Community Champion
Community Champion

@Anonymous 

yes.

try

Column = 
IF(ISBLANK([DATE]), BLANK(),
DATE(VALUE(RIGHT([DATE], 2)) + 2000, VALUE(LEFT([DATE], LEN([DATE])-4)), VALUE(MID([DATE],LEN([DATE])-3,2)))
)

do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn
az38
Community Champion
Community Champion

@Anonymous 

I was able to reproduce error if my DATE column has a 3-digits value


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

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