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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
smpa01
Community Champion
Community Champion

Calculated datetime column in Power Query not DAX

My source data is following

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMtQ1ACGlWB0krpFSbCwA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type date}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each List.Durations(#duration(0, 0, 0, 0), 24, #duration(0, 1, 0, 0))),
    #"Expanded Custom" = Table.ExpandListColumn(#"Added Custom", "Custom")
in
    #"Expanded Custom"

 

 

How can I reach here by creating a concatenation of Column1 and Custom which will yet be a datetime column

 

| Column1  	| Custom     	| datetime             	|
|----------	|------------	|----------------------	|
| 1/1/2021 	| 0.00:00:00 	| 1/1/2021 12:00:00 AM 	|
| 1/1/2021 	| 0.01:00:00 	| 1/1/2021 1:00:00 AM  	|
| 1/1/2021 	| 0.02:00:00 	| 1/1/2021 2:00:00 AM  	|
| 1/1/2021 	| 0.03:00:00 	| 1/1/2021 3:00:00 AM  	|
| 1/1/2021 	| 0.04:00:00 	| 1/1/2021 4:00:00 AM  	|
| 1/1/2021 	| 0.05:00:00 	| 1/1/2021 5:00:00 AM  	|
| 1/1/2021 	| 0.06:00:00 	| 1/1/2021 6:00:00 AM  	|
| 1/1/2021 	| 0.07:00:00 	| 1/1/2021 7:00:00 AM  	|
| 1/1/2021 	| 0.08:00:00 	| 1/1/2021 8:00:00 AM  	|
| 1/1/2021 	| 0.09:00:00 	| 1/1/2021 9:00:00 AM  	|
| 1/1/2021 	| 0.10:00:00 	| 1/1/2021 10:00:00 AM 	|
| 1/1/2021 	| 0.11:00:00 	| 1/1/2021 11:00:00 AM 	|
| 1/1/2021 	| 0.12:00:00 	| 1/1/2021 12:00:00 PM 	|
| 1/1/2021 	| 0.13:00:00 	| 1/1/2021 1:00:00 PM  	|
| 1/1/2021 	| 0.14:00:00 	| 1/1/2021 2:00:00 PM  	|
| 1/1/2021 	| 0.15:00:00 	| 1/1/2021 3:00:00 PM  	|
| 1/1/2021 	| 0.16:00:00 	| 1/1/2021 4:00:00 PM  	|
| 1/1/2021 	| 0.17:00:00 	| 1/1/2021 5:00:00 PM  	|
| 1/1/2021 	| 0.18:00:00 	| 1/1/2021 6:00:00 PM  	|
| 1/1/2021 	| 0.19:00:00 	| 1/1/2021 7:00:00 PM  	|
| 1/1/2021 	| 0.20:00:00 	| 1/1/2021 8:00:00 PM  	|
| 1/1/2021 	| 0.21:00:00 	| 1/1/2021 9:00:00 PM  	|
| 1/1/2021 	| 0.22:00:00 	| 1/1/2021 10:00:00 PM 	|
| 1/1/2021 	| 0.23:00:00 	| 1/1/2021 11:00:00 PM 	|
| 1/2/2021 	| 0.00:00:00 	| 1/2/2021 12:00:00 AM 	|
| 1/2/2021 	| 0.01:00:00 	| 1/2/2021 1:00:00 AM  	|
| 1/2/2021 	| 0.02:00:00 	| 1/2/2021 2:00:00 AM  	|
| 1/2/2021 	| 0.03:00:00 	| 1/2/2021 3:00:00 AM  	|
| 1/2/2021 	| 0.04:00:00 	| 1/2/2021 4:00:00 AM  	|
| 1/2/2021 	| 0.05:00:00 	| 1/2/2021 5:00:00 AM  	|
| 1/2/2021 	| 0.06:00:00 	| 1/2/2021 6:00:00 AM  	|
| 1/2/2021 	| 0.07:00:00 	| 1/2/2021 7:00:00 AM  	|
| 1/2/2021 	| 0.08:00:00 	| 1/2/2021 8:00:00 AM  	|
| 1/2/2021 	| 0.09:00:00 	| 1/2/2021 9:00:00 AM  	|
| 1/2/2021 	| 0.10:00:00 	| 1/2/2021 10:00:00 AM 	|
| 1/2/2021 	| 0.11:00:00 	| 1/2/2021 11:00:00 AM 	|
| 1/2/2021 	| 0.12:00:00 	| 1/2/2021 12:00:00 PM 	|
| 1/2/2021 	| 0.13:00:00 	| 1/2/2021 1:00:00 PM  	|
| 1/2/2021 	| 0.14:00:00 	| 1/2/2021 2:00:00 PM  	|
| 1/2/2021 	| 0.15:00:00 	| 1/2/2021 3:00:00 PM  	|
| 1/2/2021 	| 0.16:00:00 	| 1/2/2021 4:00:00 PM  	|
| 1/2/2021 	| 0.17:00:00 	| 1/2/2021 5:00:00 PM  	|
| 1/2/2021 	| 0.18:00:00 	| 1/2/2021 6:00:00 PM  	|
| 1/2/2021 	| 0.19:00:00 	| 1/2/2021 7:00:00 PM  	|
| 1/2/2021 	| 0.20:00:00 	| 1/2/2021 8:00:00 PM  	|
| 1/2/2021 	| 0.21:00:00 	| 1/2/2021 9:00:00 PM  	|
| 1/2/2021 	| 0.22:00:00 	| 1/2/2021 10:00:00 PM 	|
| 1/2/2021 	| 0.23:00:00 	| 1/2/2021 11:00:00 PM 	|

 

 

Thank you in advance.

 


========================
Did I answer your question? Mark my post as a solution!
Proud to be a Super User
My Custom Visualization Projects
• Plotting Live Sound: Live Sound
• Beautiful News: Women in Parliament, Energy Mix, Shrinking Armies
• Visual Capitalist: Working Hrs
• Others: Easing Graph, Animated Calendar
MayViz Submissions
• Week 1: View
• Week 2: View
• Week 3: View
• Week 4: View
========================
1 ACCEPTED SOLUTION
Jakinta
Solution Sage
Solution Sage

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMtQ1ACGlWB0krpFSbCwA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type datetime}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each List.DateTimes( [Column1], 24, #duration(0, 1, 0, 0))),
    #"Expanded Custom" = Table.ExpandListColumn(#"Added Custom", "Custom"),
    #"Duplicated Column" = Table.DuplicateColumn(#"Expanded Custom", "Custom", "datetime"),
    #"Changed Type2" = Table.TransformColumnTypes(#"Duplicated Column",{{"Column1", type date}, {"Custom", type time}, {"datetime", type datetime}})
in
    #"Changed Type2"

View solution in original post

2 REPLIES 2
CNENFRNL
Community Champion
Community Champion

Date and Time can be directly concatenated by "&" operator; thus, create a series of hours by List.Times,

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMtQ1ACGlWB0krpFSbCwA", 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 date}}),
    #"Added Times" = Table.AddColumn(#"Changed Type", "Time", each List.Times(#time(0, 0, 0), 24, #duration(0, 1, 0, 0))),
    #"Expanded Custom" = Table.ExpandListColumn(#"Added Times", "Time"),
    #"Concatenated DateTime" = Table.AddColumn(#"Expanded Custom", "DateTime", each [Date] & [Time])
in
    #"Concatenated DateTime"

 

Screenshot 2021-08-24 034409.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Jakinta
Solution Sage
Solution Sage

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMtQ1ACGlWB0krpFSbCwA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type datetime}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each List.DateTimes( [Column1], 24, #duration(0, 1, 0, 0))),
    #"Expanded Custom" = Table.ExpandListColumn(#"Added Custom", "Custom"),
    #"Duplicated Column" = Table.DuplicateColumn(#"Expanded Custom", "Custom", "datetime"),
    #"Changed Type2" = Table.TransformColumnTypes(#"Duplicated Column",{{"Column1", type date}, {"Custom", type time}, {"datetime", type datetime}})
in
    #"Changed Type2"

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors