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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
Anonymous
Not applicable

Creating Time (Hour) column/Table

Hi All, 

 

Can you please help me with the below issue? 

  • I have a report that includes 8 tables (one of which is the Date table) 
  • The query is pulled from microsoft sql server
  • I split the Datestamp columns to "Date" and "Time" and changed their data types to reflect correctly.
  • Time type is HH:MM:SS - but i'm only intersted in Hours honestly.

 

One of the tables is called "All tickets" - which includes the Ticket ID, Created time and Completed time and others non-related columns.

 

As a start I want to create a a visual "Cout of Request ID VS Created time" and "Cout of Request ID VS Created time" (So like when do I receive most tickets and when do I close most) 

 

I searched many fixes on the internet but none worked with my model. 

 

Can you please help me create a Time Table such as the Date table where I can connect it to all my tables and use it accordingly? 

2 ACCEPTED SOLUTIONS
BA_Pete
Super User
Super User

Hi @Anonymous ,

 

Paste this into a blank query in Power Query to create a dimension table similar to your Date table, but for every second of the day.

 

let
  hoursTable = Table.FromList({0..23}, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
  renHours = Table.RenameColumns(hoursTable, {{"Column1", "hours"}}),
  minutesTable = Table.FromList({0..59}, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
  secondsTable = Table.FromList({0..59}, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
  addCJminutes = Table.AddColumn(renHours, "minutes", each minutesTable),
  expandCJminutes = Table.ExpandTableColumn(addCJminutes, "minutes", {"Column1"}, {"minutes"}),
  addCJseconds = Table.AddColumn(expandCJminutes, "seconds", each secondsTable),
  expandCJseconds = Table.ExpandTableColumn(addCJseconds, "seconds", {"Column1"}, {"seconds"}),
  addTime = Table.AddColumn(expandCJseconds, "time", each Text.Combine({Text.From([hours], "en-GB"), Text.From([minutes], "en-GB"), Text.From([seconds], "en-GB")}, ":"), type text),
  chgAllTypes = Table.TransformColumnTypes(addTime, {{"time", type time}, {"hours", Int64.Type}, {"minutes", Int64.Type}, {"seconds", Int64.Type}})
in
  chgAllTypes

 

 

It has a specific hours column if that's all you're interested in, but should be easy enough to edit it however you want.

 

Pete 



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




View solution in original post

Icey
Community Support
Community Support

Hi @Anonymous ,

 

You can also create a time table using DAX like below and set the data type as "Time":

Time Table =
VAR Hours_ =
    SELECTCOLUMNS ( GENERATESERIES ( 0, 23, 1 ), "Hour_", [Value] )
VAR Minutes_ =
    SELECTCOLUMNS ( GENERATESERIES ( 0, 59, 1 ), "Minute_", [Value] )
VAR Seconds_ =
    SELECTCOLUMNS ( GENERATESERIES ( 0, 59, 1 ), "Second_", [Value] )
RETURN
    SELECTCOLUMNS (
        CROSSJOIN ( Hours_, Minutes_, Seconds_ ),
        "Time",
            CONVERT ( [Hour_] & ":" & [Minute_] & ":" & [Second_], DATETIME )
    )

time table.JPG

 

 

If you only need hours, try this:

Time Table just with Hours = 
SELECTCOLUMNS (
    GENERATESERIES ( 0, 23, 1 ),
    "Time", CONVERT ( [Value] & ":00:00", DATETIME )
)

time table just with hour.JPG

 

 

Best Regards,

Icey

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Icey
Community Support
Community Support

Hi @Anonymous ,

 

You can also create a time table using DAX like below and set the data type as "Time":

Time Table =
VAR Hours_ =
    SELECTCOLUMNS ( GENERATESERIES ( 0, 23, 1 ), "Hour_", [Value] )
VAR Minutes_ =
    SELECTCOLUMNS ( GENERATESERIES ( 0, 59, 1 ), "Minute_", [Value] )
VAR Seconds_ =
    SELECTCOLUMNS ( GENERATESERIES ( 0, 59, 1 ), "Second_", [Value] )
RETURN
    SELECTCOLUMNS (
        CROSSJOIN ( Hours_, Minutes_, Seconds_ ),
        "Time",
            CONVERT ( [Hour_] & ":" & [Minute_] & ":" & [Second_], DATETIME )
    )

time table.JPG

 

 

If you only need hours, try this:

Time Table just with Hours = 
SELECTCOLUMNS (
    GENERATESERIES ( 0, 23, 1 ),
    "Time", CONVERT ( [Value] & ":00:00", DATETIME )
)

time table just with hour.JPG

 

 

Best Regards,

Icey

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

BA_Pete
Super User
Super User

Hi @Anonymous ,

 

Paste this into a blank query in Power Query to create a dimension table similar to your Date table, but for every second of the day.

 

let
  hoursTable = Table.FromList({0..23}, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
  renHours = Table.RenameColumns(hoursTable, {{"Column1", "hours"}}),
  minutesTable = Table.FromList({0..59}, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
  secondsTable = Table.FromList({0..59}, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
  addCJminutes = Table.AddColumn(renHours, "minutes", each minutesTable),
  expandCJminutes = Table.ExpandTableColumn(addCJminutes, "minutes", {"Column1"}, {"minutes"}),
  addCJseconds = Table.AddColumn(expandCJminutes, "seconds", each secondsTable),
  expandCJseconds = Table.ExpandTableColumn(addCJseconds, "seconds", {"Column1"}, {"seconds"}),
  addTime = Table.AddColumn(expandCJseconds, "time", each Text.Combine({Text.From([hours], "en-GB"), Text.From([minutes], "en-GB"), Text.From([seconds], "en-GB")}, ":"), type text),
  chgAllTypes = Table.TransformColumnTypes(addTime, {{"time", type time}, {"hours", Int64.Type}, {"minutes", Int64.Type}, {"seconds", Int64.Type}})
in
  chgAllTypes

 

 

It has a specific hours column if that's all you're interested in, but should be easy enough to edit it however you want.

 

Pete 



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Helpful resources

Announcements
October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.