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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Jaylocks1990
Frequent Visitor

Column with mixed date types - half is mm/dd/yyyy, half is dd/mm/yyyy - How do I resolve?

Hey all, 

 

Pretty new with PowerBI so please bear with me. 

 

I have created a MS flow that scrapes a Teams Channel and adds the content to an Excel table that has the headings:

Sender

Date/Time

Message ID (unique number attached to each message)

Content

 

Unfortunately, the UTC conversion step in the flow appears to have been off somehow because the date format switches over halfway through the month like so:

2020-06-08 18_07_03-All Channel Message capture.xlsx  -  Repaired - Excel.png

 

The issue is present in the source data, so PowerBI is recreating the same issue in power query:

2020-06-08 17_31_37-Table2 - Power Query Editor.png

This has happened every half month for the last 3 months, so I now have data that is half mm/dd/yyyy (which I don't want) and half dd/mm/yyyy which I do want. 

 

The spreadsheet which this has happened to is a live document, with many messages being added to it constantly, so I cannot do large modifications to it.

 

I have tried:

Setting the date type 'by locale' (I am in NZ) but this has not helped. 

 

Creating a custom column using an expression I found here, also from this forum. 

 

Exporting a total copy of the spreadsheet and manually trying to change the month column to text so I can identify it but I still need a way to be able to convert the numbers into correct order first before changing the month to text to prevent reoccurence.

 

Tried splitting the date column and recombining but this does not work because they are half correct, and half incorrect so I just kind of swapped the problem over. 

 

I can't seem to figure out a way to only modify the half of the column that I need to change, lots of really great advice and videos about how to change whole columns to the correct format but I can't find anything about how to do specific parts of the column that I need.

 

 Any help will be appreciated. 

 

Jaylocks

 

2 ACCEPTED SOLUTIONS

Ohhhh.   If you know that the incorrect format stops at a certain index value, you can just use this approach ...

 

=if [Index] <12345 then Text.BetweenDelimiters([Date],"/","/")&"/"&Text.BeforeDelimiter([Date],"/",0)&"/"&Text.AfterDelimiter([Date],"/",1) else [Date]

 

Does that work?  Not sure the index where it stops (or if the logic is more complext), but you get the idea.

 

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


View solution in original post

Hey @mahoneypat

 

Thanks for your suggestion here earlier, I apologise for not getting back to you. 

 

The solution I went with in the end was: 

1. Open up the query editor

2. Select all the obviously wrong values from the filter list on the date column, fortunately I caught this before it was not clear which way round it should go (without going back to source data and confirming the message contents there) 

2020-06-26 15_24_22-Window.png

3. Manually change the incorrect dates round to correct with the 'Replace values' button

2020-06-26 15_27_09-.png

4. Once I did that I went to the applied steps window and removed the 'Filtered Rows' steps:

2020-06-26 15_28_50-Window.png

Step 4 was what I was missing in a previous attempt. 

 

This then gave me a column full of correct dates that could be used for analysis. 

 

Many thanks all for your assistance here, I was under a lot of pressure to sort it out. 

 

 

View solution in original post

12 REPLIES 12

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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