March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hey all,
I need help formatting date and time columns. In my source, the date and time are displayed as follows:
The goal is to format the date and time correctly without performing various transformation steps (e.g. function "Text.PadStart"). For the columns that contain the times, I have managed to get the dates to display correctly with a lot of steps. But I'm sure it can be done even easier 😉
As for the date, transforming it to text and then to date works, but there are also rows that show "0". Here there is then logically an error and the function "Replace error" does not work, because there then a value in the date format is expected.
Thanks in advance and many greetings,
Paddy
OK, for the times we could 'split column by position' (by 6 chars as far right as possible) then Text.PadStart( to 6 chars using "0") and then change datatype to Time. I don't know if that's any quicker than the steps you have but it should work.
These are exactly the steps I have made.
Isn't there any quicker solution?
Hi @Pmasuch ,
Here is my steps. hope this helps.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("LcnBDcAgDATBXu7Ng1s7Ca4Fuf82UCTmO3uLSczk0ZBJU7WglnrcC+K/5HU4/SXqPg==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Datum_Rewrite = _t, Uhrzeit_Rewrite = _t]),
Custom1 = Table.TransformColumns(Source,{"Uhrzeit_Rewrite",each Text.Start(_,6)}),
#"Changed Type" = Table.TransformColumnTypes(Custom1,{{"Datum_Rewrite", type date}, {"Uhrzeit_Rewrite", type time}}),
#"Merged Columns" = Table.CombineColumns(Table.TransformColumnTypes(#"Changed Type", {{"Datum_Rewrite", type text}, {"Uhrzeit_Rewrite", type text}}, "en-US"),{"Datum_Rewrite", "Uhrzeit_Rewrite"},Combiner.CombineTextByDelimiter(" ", QuoteStyle.None),"Merged"),
#"Changed Type1" = Table.TransformColumnTypes(#"Merged Columns",{{"Merged", type datetime}})
in
#"Changed Type1"
Best Regards,
Gao
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum
Hi Gao,
thanks for your solution, but I need not a merged column. Date and time should stay seperated from each other.
It works with the following steps:
In the browser, the affected columns look fine, transformed as dates (Image 1).
Unfortunately, when I display the raw dataflow without transformations in Power BI Desktop, this is not the case (image 2).
Do you have an explanation for this?
Thank you and best regards
Hi,
thank you, the date looks fine, now!
The column "Uhrzeit_Rewrite" shows the time, but in a wrong format with 11 or 12 digits. Here only the first 4 or 5 are needed, for the representation of hours, minutes and seconds. And this of course in the time format, e.g. 08:15:22 (German time format).
Greetings
Greetings
What do the Uhrzeit_Rewrite values represent? Do you have an algorithm we can use?
--
For the date values, you can have null dates but you can't have zero dates. So you can Replace Values or Replace Errors, whichever is easier for you.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.