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
galbatrox9
Helper I
Helper I

Power Query - Error while rounding off time

Hi Team,

 

I wanted to round off my time column into the nearest hour in Power Query and it worked for most of the data, but about 20% of the data has errors now and I am not able to understand why. 

Here's a snapshot and this is the code I used : Time.From(Number.Round(Number.From([IST Time])*24)/24)

Capture.JPG

 

Can anyone help me understand how to fix this? Or suggest a better code to use.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Well you can use the DAX to create a caluclated column on your original table or recreate the table as a visual and add a column for the measure. Should make it fairly easy to determine if there were any errors.

View solution in original post

8 REPLIES 8
Anonymous
Not applicable

Hey @galbatrox9 

 

You don't have to use DAX for this. I would just duplicate the column, retitle it, and then in query editor change the format to HH under the Transform tab. See this article for more information: https://docs.microsoft.com/en-us/dax/custom-date-and-time-formats-for-the-format-function

 

If this helps please kudo.

If this answers your question please accept it as a solution.

Hi @Anonymous ,

 

Thats neat, but what if i wanted to round to the nearest hour? In your way, 10:45 PM would be converted to 10 PM, but i want it to come to 11 PM.

Anonymous
Not applicable

My bad. I forgot formatting doesn't round. In that case you were on the right track. The answer you're looking for is in this post: https://community.powerbi.com/t5/Desktop/How-to-round-minutes-in-time-to-the-nearest-hour/td-p/47643...

Haha the code I used was exactly from that link! But its giving me errors on some lines.

Anonymous
Not applicable

Haha I see that now. Have you tried the DAX solution instead of the M option?

 

If it has to be M try this thread: https://community.powerbi.com/t5/Desktop/Round-Down-to-Nearest-30-Minute-Interval-Query-Editor/td-p/...

I just tried the Dax solution. Do you know a way to check if there are errors in that? From the filter dropdown, i cant see any errors. @Anonymous 

Anonymous
Not applicable

Well you can use the DAX to create a caluclated column on your original table or recreate the table as a visual and add a column for the measure. Should make it fairly easy to determine if there were any errors.

Anonymous
Not applicable

Only concern with this is I believe it makes it based on a 24 hour clock and I'm not sure how to convert it to 12 hour if that is what you need.

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 Fabric 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.