cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
christoR1 Regular Visitor
Regular Visitor

How to create a TimeKey from a time column in hh:mm:ss format.

Hi team

 

How can i create a TimeKey column from a Time column in powerquery.

The timekey column will be in seconds from 1-86400. 
This is similar to creating a datakey eg: 2019-06-13 to 20190613. 

The idea behind creating a timekey is to join this fact table key to a timekey in a time dimension table in my dw which would allow for the data to be sliced by different time fields.

i would prefer to do this in Power Query.

 

timekey.jpg

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: How to create a TimeKey from a time column in hh:mm:ss format.

Hi,

 

Enter the Query Editor, click on your query, go to tab "Add Column" -> "Custom Column", enter column name and formula like code below, adjust the code by adding ",Int64.Type". Don't forget to click the "Close & Apply" button.

 

Time.Hour([Time])*60*60+Time.Minute([Time])*60+Time.Second([Time])

time to second.png

 

 

 

Best Regards,

Amy

 

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

4 REPLIES 4
Community Support Team
Community Support Team

Re: How to create a TimeKey from a time column in hh:mm:ss format.

Hi @christoR1 ,

 

Enter the Query Editor, click on your query, go to tab "Add Column" -> "Custom Column", enter column name and formula like code below, adjust the code by adding ", type time". Don't forget to click the "Close & Apply" button.

 

=#time(0,0,0) + #duration(0,0,0,[TimeKey])

 

Adding a custom column in the Query Editor(1).png

Best Regards,

Amy

 

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

Highlighted
christoR1 Regular Visitor
Regular Visitor

Re: How to create a TimeKey from a time column in hh:mm:ss format.

Hi @v-xicai , Unfortuantely thats not what i am after as i already have a time column! 

I am trying to convert time from hh:mm:ss to seconds (wholenumber). This would then form a key to be joined to a time dimension table.

Community Support Team
Community Support Team

Re: How to create a TimeKey from a time column in hh:mm:ss format.

Hi,

 

Enter the Query Editor, click on your query, go to tab "Add Column" -> "Custom Column", enter column name and formula like code below, adjust the code by adding ",Int64.Type". Don't forget to click the "Close & Apply" button.

 

Time.Hour([Time])*60*60+Time.Minute([Time])*60+Time.Second([Time])

time to second.png

 

 

 

Best Regards,

Amy

 

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

Community Support Team
Community Support Team

Re: How to create a TimeKey from a time column in hh:mm:ss format.

Hi  @christoR1 ,

 

Does that make sense? If so, kindly mark my answer as a solution to help others having the similar issue and close the case. If not, let me know and I'll try to help you further.

 

Best regards

Amy

Helpful resources

Announcements
Exclusive LIVE Community Event #3 – Ask Arun Anything

Exclusive LIVE Community Event #3 – Ask Arun Anything

Join us in the third Triple A event!

Meet the 2020 Season 1 Power BI Super Users!

Meet the 2020 Season 1 Power BI Super Users!

It’s the start of a new Super User season! Learn all about the new Super Users and brand-new tiered recognition system.

Super User Challenge: Can You Solve These?

Super User Challenge: Can You Solve These?

We're celebrating the start of the New Super User season with our first ever Super User 'Can You Solve These?' challenge.

Power BI Desktop Update - February 2020

Power BI Desktop Update - February 2020

We are super excited for our update this month, as we are releasing two of our top community requests!

Power Platform Online Conference

Power Platform Online Conference

Join us for the first ever Power Platform Online Conference!

Top Solution Authors