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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Create a Timestamp from multiple columns in power query

Hello,

 

I'm relatively new to Power BI. I am pulling in data from an API source, which separates out date and time into multiple columns. The data looks like this...

YearMonthDayHour
201911250

 

I need to create a new column that combines these into a single timestamp.   

 

11/25/2019 12:00:00 AM

 

In M code, how can I create a custom column that combines these columns into a timestamp?

 

Thank you for your help!

1 ACCEPTED SOLUTION

you can just concatenate the time-value with the date-value like so:

 

DateTime.From(#date([Year],[Month],[Day]) & #time([Hour],0,0))

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

View solution in original post

4 REPLIES 4
Nathaniel_C
Community Champion
Community Champion

Hi @Anonymous ,
This will get you part of the way. Go to Add Column tab, Custom Column. Not sure how the Hour is converted, though.
Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathanielconverttime.PNG

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Anonymous
Not applicable

This does work for the date piece. I tried using Time.From([Hour]), but I'm getting an error on everything less than 10. Is it a formatting issue?

Hi @Anonymous ,
I have tried changing the data type, etc.  Time to call for the Magician of M. @ImkeF 
Nathaniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




you can just concatenate the time-value with the date-value like so:

 

DateTime.From(#date([Year],[Month],[Day]) & #time([Hour],0,0))

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.