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.
I have the following fields:
[Date] data type: date setting: M/D/YYYY sample value: 9/1/2020
[Time] data type: text format: H:MM:SS AM/PM TZ sample value: 8:05:30 AM ET
I need to create a derived field of type date/time/timezone in Power Query using these two fields. How can I create this field? For example, for the sample values above, I expect an output like:
9/1/2020 8:05:30 AM -05:00
Solved! Go to Solution.
Hi @Anonymous ,
Go to query editor,select column "Time">"Transform">"Split column":
And you will see:
Then create a custom column as below:
Finally you will see:
For the M codes,see below:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WstQ31DcyMDJQ0lGysDIwtTI2UHD0VXANUYqNBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, Time = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Time", type text}}),
#"Split Column by Delimiter" = Table.SplitColumn(#"Changed Type", "Time", Splitter.SplitTextByEachDelimiter({" "}, QuoteStyle.Csv, true), {"Time.1", "Time.2"}),
#"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Time.1", type time}, {"Time.2", type text}}),
#"Added Custom2" = Table.AddColumn(#"Changed Type1", "Custom.1", each DateTime.AddZone([Date]&[Time.1],-5))
in
#"Added Custom2"
Attachment is the related .pbix file.
Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!
Hi @Anonymous ,
Does your data exist in tables?If possible,could you pls provide a table format,not just show the field.It would be more convenient to do the data transformation.
Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!
Hi @Anonymous ,
Go to query editor,select column "Time">"Transform">"Split column":
And you will see:
Then create a custom column as below:
Finally you will see:
For the M codes,see below:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WstQ31DcyMDJQ0lGysDIwtTI2UHD0VXANUYqNBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, Time = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Time", type text}}),
#"Split Column by Delimiter" = Table.SplitColumn(#"Changed Type", "Time", Splitter.SplitTextByEachDelimiter({" "}, QuoteStyle.Csv, true), {"Time.1", "Time.2"}),
#"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Time.1", type time}, {"Time.2", type text}}),
#"Added Custom2" = Table.AddColumn(#"Changed Type1", "Custom.1", each DateTime.AddZone([Date]&[Time.1],-5))
in
#"Added Custom2"
Attachment is the related .pbix file.
Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!
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 |
---|---|
118 | |
107 | |
70 | |
70 | |
43 |
User | Count |
---|---|
148 | |
104 | |
104 | |
89 | |
66 |