Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Hello everybody,
I have a field in format of time like 9:03:45 or 9:46:12.
I need to make a new field where I would round the times to the nearest hour, for example:
9:03:45 -> 9:00
9:46:12 -> 10:00
How can I do that in Power BI?
Thank you.
Tereza
Solved! Go to Solution.
Hi @TessGaston
You can do this in DAX or M languages depending where you want the calculation to happen.
If <original time> is the original time value:
DAX:
Round time to nearest hour ( TIME(1,0,0) = 1/24 representing an hour) and add a zero time value to ensure the expression is cast as a Time.
MROUND ( <original time>, TIME ( 1, 0, 0 ) ) + TIME ( 0, 0, 0 )
M:
There isn't an equivalent of MROUND in M, so instead multiply the time by 24 to express it as a number of hours, then round, then divide by 24 and convert to a Time type.
Time.From( Number.Round( Number.From( <original time> ) * 24 ) / 24 )
Regards,
Owen
Hi @TessGaston,
Have you solved your problem?
If you have solved, please always accept the replies making sense as solution to your question so that people who may have the same question can get the solution directly.
Best Regards,
Cherry
Hi @TessGaston
You can do this in DAX or M languages depending where you want the calculation to happen.
If <original time> is the original time value:
DAX:
Round time to nearest hour ( TIME(1,0,0) = 1/24 representing an hour) and add a zero time value to ensure the expression is cast as a Time.
MROUND ( <original time>, TIME ( 1, 0, 0 ) ) + TIME ( 0, 0, 0 )
M:
There isn't an equivalent of MROUND in M, so instead multiply the time by 24 to express it as a number of hours, then round, then divide by 24 and convert to a Time type.
Time.From( Number.Round( Number.From( <original time> ) * 24 ) / 24 )
Regards,
Owen
Thank you very much! Simple and very effective solution
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
145 | |
85 | |
66 | |
52 | |
48 |
User | Count |
---|---|
215 | |
90 | |
83 | |
67 | |
59 |