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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Anonymous
Not applicable

Change time format from hh:mm:s to hh:mm:ss

Hello,

 

I would like to change the time format from hh:mm:s to hh:mm:ss.

 

I used the following  measure:

PCR =
Var vSeconds = 'Medidas'[Average]
var vMinutes = int(vSeconds/60)
var vRemainingSeconds= int(MOD(vSeconds,60))
var vHours = INT(vMinutes/60)
var vRemainingMinutes=MOD(vMinutes,60)
return
vHours&
vRemainingMinutes&":"&
vRemainingSeconds
 
The output is: 
claud2022_0-1643714041737.png

 

But I would like to see the 0 before the number when the seconds don't reach 10. Something like this:

03:14

03:16

03:04

03:08

 

claud2022_1-1643714682192.png

 

What measure should I use to get it?

 

Thanks in advance for your help!

 

 

2 ACCEPTED SOLUTIONS
Samarth_18
Community Champion
Community Champion

HI @Anonymous ,

You can update your code like this:-

PCR =
VAR vSeconds = 'Medidas'[Average]
VAR vMinutes =
    INT ( vSeconds / 60 )
VAR vRemainingSeconds =
    INT ( MOD ( vSeconds, 60 ) )
VAR vHours =
    INT ( vMinutes / 60 )
VAR vRemainingMinutes =
    MOD ( vMinutes, 60 )
RETURN
    vHours & vRemainingMinutes & ":"
        & IF ( vRemainingSeconds < 9, "0" & vRemainingSeconds, vRemainingSeconds )

 

Thanks,

Samarth

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

View solution in original post

Anonymous
Not applicable

I  updated it and it's working

Thanks a lot !! @Samarth_18 

 

View solution in original post

2 REPLIES 2
Samarth_18
Community Champion
Community Champion

HI @Anonymous ,

You can update your code like this:-

PCR =
VAR vSeconds = 'Medidas'[Average]
VAR vMinutes =
    INT ( vSeconds / 60 )
VAR vRemainingSeconds =
    INT ( MOD ( vSeconds, 60 ) )
VAR vHours =
    INT ( vMinutes / 60 )
VAR vRemainingMinutes =
    MOD ( vMinutes, 60 )
RETURN
    vHours & vRemainingMinutes & ":"
        & IF ( vRemainingSeconds < 9, "0" & vRemainingSeconds, vRemainingSeconds )

 

Thanks,

Samarth

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

Anonymous
Not applicable

I  updated it and it's working

Thanks a lot !! @Samarth_18 

 

Helpful resources

Announcements
July 2024 Power BI Update

Power BI Monthly Update - July 2024

Check out the July 2024 Power BI update to learn about new features.

Top Solution Authors