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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Charlieb
Regular Visitor

Extract date from text - very difficult

Hi,

 

As suggested here, rather than reading from a live .csv to obtain data, I am connected to a folder which will read a dated file, created each day.

 

Lets assume the filename is 'file_name_2023.08.23.csv'

 

There is a column on my table called Source.Name. This has this filename inside. I create a new column called Date, inside is this function (assume the 2 numbers match my filename).

 

 

Date = DATEVALUE(MID([Source.Name], 18, 10))

 

 

I get an error, saying "Cannot convert value '2023.08.23' of type Text to type Date.

 

This doesn't appear to make a lot of sense?

1 ACCEPTED SOLUTION
Sullyball2a
Frequent Visitor

Using the following as a calculated column in Power BI Desktop should work
= DATE(MID(test[Source.Name],24,4),MID(test[Source.Name],21,2),MID(test[Source.Name],18,2))
...but you are much better doing this as an additional column from examples in Power Query

View solution in original post

3 REPLIES 3
Sullyball2a
Frequent Visitor

Using the following as a calculated column in Power BI Desktop should work
= DATE(MID(test[Source.Name],24,4),MID(test[Source.Name],21,2),MID(test[Source.Name],18,2))
...but you are much better doing this as an additional column from examples in Power Query

Thanks, that worked. I'm not sure if Power Query is a thing in the online version of PowerBI?

where "test" is the table name - replace "test" with your table name in the formula

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.