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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Patryk_PL_92
Helper I
Helper I

PQ - Mixed date types in one column mm/dd/yyyy and dd/mmm/yyyy

Hello,

 

I pull data from Sharepoint folder which contains many CSV files, all files got same layout.

There is a problem with dates, as shown on below image.

 

Some dates are read by PQ correctly - as mm/dd/yyyy, but some are in incorrect format dd/mmm/yyyy.

 

How can I unify those dates, to have only the desired type which is mm/dd/yyyy?

I have no idea what approach can I take, what kind of transformation can I do to achieve that...

 

Initially this column is in "ANY" data type, when I change to "DATE/TIME" format then PQ throws an error, saying:
"We couln't parse the input provided as a DateTime value."

 

Patryk_PL_92_0-1651665856179.png

 

1 ACCEPTED SOLUTION

You need to put this formula in a custom column not in formula bar. If you want to put in formula bar, then use following formula where Previous step should be replaced with your previous step

= Table.AddColumn(#"Previous Step", "Custom", each Date.From(Text.Select(Text.BeforeDelimiter([Date Column]," ",{0, RelativePosition.FromEnd}),{"0".."9","/","a".."z","A".."Z"," "})))

View solution in original post

4 REPLIES 4
Vijay_A_Verma
Super User
Super User

Use this formula to convert your existing values to date format (Change Date Column appopriately)

= Date.From(Text.Select(Text.BeforeDelimiter([Date Column]," ",{0, RelativePosition.FromEnd}),{"0".."9","/","a".."z","A".."Z"," "}))

 

You need to put this formula in a custom column not in formula bar. If you want to put in formula bar, then use following formula where Previous step should be replaced with your previous step

= Table.AddColumn(#"Previous Step", "Custom", each Date.From(Text.Select(Text.BeforeDelimiter([Date Column]," ",{0, RelativePosition.FromEnd}),{"0".."9","/","a".."z","A".."Z"," "})))

Hi Vijay,

 

amazing formula, worked well for most of records 🙂

I found out that some dates are corrupted, so I needed to clean that up in the source.

 

Accepted as Solution.

Hello Vijay
thanks for response on that

I tried to use your formula, but it does not work for me or simply I do not know how to use it.

 

This is my column name and type:

Patryk_PL_92_0-1651735046495.png

 

And this is error I get when I use that formula - it seems that formula is not identifying [Execution Date] as a column name:

Patryk_PL_92_2-1651735307676.png

 

Any tips how to implement that correctly?

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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