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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
masplin
Impactful Individual
Impactful Individual

Converting hh:mm:ss to hh:mm

I have inherited a modle with a huge number of times hh:mm:ss and think it  the precision is uneccessary and causing a lot of additional strain. Is there an easy way to reformat these as hh:mm in Power Q?

 

Thanks

 

Mike 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

In the current column, it will only change display

create a new column

new column = format(table[time],"HH:MM") and change data time

or

new column = time(hour(table[time]),minute(table[time]),0)

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

8 REPLIES 8
amitchandak
Super User
Super User

In the current column, it will only change display

create a new column

new column = format(table[time],"HH:MM") and change data time

or

new column = time(hour(table[time]),minute(table[time]),0)

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
masplin
Impactful Individual
Impactful Individual

Great presumably this just tuncated so 14:30:44 becomes 14:30? Is there an equivalent to rounding so it became 14:31?

 

Thanks

Mike

Hi,

 

Please try this calculated column:

Column = IF(SECOND('Test'[Time])<=30,FORMAT('Test'[Time],"HH:MM"),FORMAT(TIME(HOUR('Test'[Time]),MINUTE('Test'[Time])+1,0),"HH:MM"))

And it shows:

121.PNG

 

Best Regards,

Giotto Zhi

Do you have an M equivalent as trying to reduce the cardinality in the model so needs to be done in the query?

 

Thanks


@masplin wrote:

Do you have an M equivalent as trying to reduce the cardinality in the model so needs to be done in the query?

 


To convert the DAX formula with the IF to a similar M expression you could do the following

= if Time.Second([Custom]) > 30 
then #time(Time.Hour([Custom]), Time.Minute([Custom])+1, 0)
else #time(Time.Hour([Custom]), Time.Minute([Custom]),0)

 

In theory I figured that the first expression would be much more expensive due to casting to and from a string. But I did some rough benchmarking and it is slower than the #time constructor, but only by about 5% in my tests. 

You could add a new custom column with the following formula

 

Time.FromText( Time.ToText([Column1],"HH:mm"))

 

Then delete the original column and rename this new column 

Actually I think the following expression is probably better than my previous suggestion converting to and from a string:

#time(Time.Hour([Column1]), Time.Minute([Column1]),0) 

 (I got this suggestion from Imke at https://thebiaccountant.com )

masplin
Impactful Individual
Impactful Individual

why is this better as your first suggestion seeme dfine?

 

Thanks

Mike

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors
Top Kudoed Authors