- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Convert 24 HR time
Hi,
I have a column of time data in 24 Hr time:
Time
625
844
1241
1556
Where 625 is 06:25 AM.
How can I convert this into a usable form for PowerBI?
Thank you,
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The first formula I supplied is DAX. That is the one that starts with "Column =". You use that version after you have run your query and are out of the Query Editor window and in Power BI Desktop. You go to the Data tab (middle icon on the left) and go to "Modeling" and then "New Column". That is where you would use the FIRST formula.
The SECOND formula is when you are in the Query Editor window and go to "Add Column" in the ribbon and then New Column. You seem to be using the DAX query when you should be using the M query and using the M query when you should be using the DAX query.
Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!: Power BI Cookbook Third Edition (Color)
DAX is easy, CALCULATE makes DAX hard...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Maybe you want to use something shorter:
Col = REPLACE([Hora],IF(LEN([Hora])=3,2,3),0,":")
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Maybe you want to use something like this:
Col = REPLACE([Hora],IF(LEN([Hora])=3,2,3),0,":")
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Column = CONCATENATE(CONCATENATE(LEFT([Time],LEN([Time])-2),":"),RIGHT([Time],2))
Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!: Power BI Cookbook Third Edition (Color)
DAX is easy, CALCULATE makes DAX hard...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I received the following message: Expression error: The name 'CONCATENATE' wasn't recognized. Make sure it's spelled correctly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
M code version:
= Text.Middle(Text.From([Time]),0,Text.Length(Text.From([Time])) - 2) & ":" & Text.Middle(Text.From([Time]),Text.Length(Text.From([Time]))-2,2)
This assumes that your original data is a Number, hence the Text.From functions. If you have converted it to Text, you don't need those although the formula as presented will work with either Text or Number as the original data type for [Time] column.
Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!: Power BI Cookbook Third Edition (Color)
DAX is easy, CALCULATE makes DAX hard...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I received the following error:
The syntax for '.' is incorrect. (DAX(Text.Middle(Text.From([ACTUAL_TIME]),0,Text.Length(Text.From([ACTUAL_TIME])) - 2) & ":" & Text.Middle(Text.From([ACTUAL_TIME]),Text.Length(Text.From([ACTUAL_TIME]))-2,2))).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is it still M or DAX?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The first formula I supplied is DAX. That is the one that starts with "Column =". You use that version after you have run your query and are out of the Query Editor window and in Power BI Desktop. You go to the Data tab (middle icon on the left) and go to "Modeling" and then "New Column". That is where you would use the FIRST formula.
The SECOND formula is when you are in the Query Editor window and go to "Add Column" in the ribbon and then New Column. You seem to be using the DAX query when you should be using the M query and using the M query when you should be using the DAX query.
Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!: Power BI Cookbook Third Edition (Color)
DAX is easy, CALCULATE makes DAX hard...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
For the first I receive the following error:
An argument of function 'LEFT' has the wrong data type or has an invalid value.
What's the difference beteen DAX and M?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
What is the data type of your "Time" column? Is your Time column called "Time"? I tested with the Time column being Whole Number and Text.
The difference between DAX and M are that they are two completely different languages. DAX is used with PowerPivot (the in-memory data model that Power BI uses). M is used with Power Query, the extract, transform and load (ETL) system that Power BI uses.
Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!: Power BI Cookbook Third Edition (Color)
DAX is easy, CALCULATE makes DAX hard...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Whole Number for both.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try switch [ACTUAL_TIME] to Text, it is the ?Data Type" drop down. Weird. If that doesn't work, copy and paste your formula into a response so that I can copy and paste it exactly and recreate this.
Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!: Power BI Cookbook Third Edition (Color)
DAX is easy, CALCULATE makes DAX hard...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'll worry about it later. You're second query worked so I'll just work off that. Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That would be because you were trying to enter a DAX formula into the Query Editor, which uses "M". Import your data and then in the Data tab, go to Modeling in the ribbon and "New Column". I'll see if I can post the equivalent M formula, but please note that you are posting to a forum on DAX Tips and Tricks, not Power Query "M" Tips and Tricks.
Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!: Power BI Cookbook Third Edition (Color)
DAX is easy, CALCULATE makes DAX hard...

Helpful resources
Subject | Author | Posted | |
---|---|---|---|
12-21-2022 08:02 PM | |||
11-20-2024 06:03 PM | |||
09-24-2024 02:39 AM | |||
10-23-2024 06:24 AM | |||
06-26-2024 03:06 AM |
User | Count |
---|---|
13 | |
11 | |
10 | |
10 | |
9 |
User | Count |
---|---|
29 | |
16 | |
15 | |
13 | |
12 |