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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors