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.
Hello! I'm trying to convert this table into a date:
It has values as dd/mm/yy, but its not formatted propperly, how can I change them to make them look like 1/02/22, for example?
Solved! Go to Solution.
Hi,
you can create a custom column
(if Text.Length([Column1]) = 5 then Text.Start([Column1],1)&"/"&Text.Middle([Column1],1,2) else Text.Start([Column1],2)&"/"&Text.Middle([Column1],2,2))&"/"&Text.End([Column1],2)
and then change type to Date
If this post is useful to help you to solve your issue consider giving the post a thumbs up
and accepting it as a solution !
Hi @Anonymous ,
I'd probably try to fix it in Power Query:
Add a new custom column and use the following code:
= Table.AddColumn(#"Changed Type", "Custom", each Text.Insert ( Text.Insert ( Text.From ([Date]), Text.Length([Date]) - 2, "/"), Text.Length([Date]) - 4, "/"))
Here the code in Power Query M that you can paste into the advanced editor (if you do not know, how to exactly do this, please check out this quick walkthrough)
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQwMjJSitWJVjKyNDAxtIQwDQwNjQzBTGMDYyMDpdhYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type text}}), #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each Text.Insert ( Text.Insert ( Text.From ([Date]), Text.Length([Date]) - 2, "/"), Text.Length([Date]) - 4, "/")) in #"Added Custom"
Note, the column needs to be in text format for the code to function. Also, the code will only work if the data is either in the format DDMMYY or DMMYY. If your data happens to be DDMYY or DMYY, it won't work.
Let me know, if this helped to solve your issue 🙂
/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/
Did I answer your question❓➡️ Please, mark my post as a solution ✔️ |
Also happily accepting Kudos 🙂 |
Feel free to connect with me on LinkedIn! |
#proudtobeasuperuser |
Hello! Trying to do it as your first method shows me this:
And if I expand it for "Custom" It shows me an error
Hi @Anonymous ,
Interesting... Does it work this way? 🙂
Code
Text.Insert ( Text.Insert ( Text.From ([Date]), Text.Length([Date]) - 2, "/"), Text.Length([Date]) - 4, "/")
/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/
Did I answer your question❓➡️ Please, mark my post as a solution ✔️ |
Also happily accepting Kudos 🙂 |
Feel free to connect with me on LinkedIn! |
#proudtobeasuperuser |
Hi,
you can create a custom column
(if Text.Length([Column1]) = 5 then Text.Start([Column1],1)&"/"&Text.Middle([Column1],1,2) else Text.Start([Column1],2)&"/"&Text.Middle([Column1],2,2))&"/"&Text.End([Column1],2)
and then change type to Date
If this post is useful to help you to solve your issue consider giving the post a thumbs up
and accepting it as a solution !
Thanks! It worked just fine!
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
110 | |
99 | |
80 | |
64 | |
57 |
User | Count |
---|---|
145 | |
110 | |
91 | |
84 | |
66 |