emitir tiempo formato mm:ss.00 formulario

Un usuario Pregunto ✅

davorgom

Hola,

Tengo un problema al tratar de obtener cronometradores en power bi en formato mm:ss.00. Alguien sabe como puedo hacerlo?

greg_deckler

En respuesta a davorgom

Dale un giro a esto. Voy a publicarlo en la Galería de medidas rápidas. Se basa en la publicación de blog con la que respondí anteriormente.

Duration Milliseconds = 
// Duration formatting 
// * Based on @konstatinos and @Greg_Deckler blog post 
// https://community.powerbi.com/t5/Community-Blog/Aggregating-Duration-Time/ba-p/22486 1/25/2016
// * Given a number of milliseconds, returns a format of "hh:mm:ss:000 format"
//
// We start with a duration in number of milliseconds
VAR Duration = SUM(Milliseconds[Milliseconds])
// There are 3,600,000 milliseconds in an hour
VAR Hours = INT ( Duration / 3600000)
// There are 60,000 milliseconds in a minute
VAR Minutes = INT ( MOD( Duration - ( Hours * 3600000 ),3600000 ) / 60000)
// There are 1000 milliseconds in a second  
VAR Seconds = INT (MOD ( MOD( Duration - ( Hours * 3600000 ) - (Minutes * 60000),60000 ), 60000 ) / 1000)
VAR Milli = ROUNDUP(MOD(MOD ( MOD( Duration - ( Hours * 3600000 ),3600000 ), 60000 ), 1000),0)
// These intermediate variables ensure that we have leading zero's concatenated onto single digits
// Hours with leading zeros
VAR H =
    IF ( LEN ( Hours ) = 1, 
        CONCATENATE ( "0", Hours ),
        CONCATENATE ( "", Hours )
      )
// Minutes with leading zeros
VAR M =
    IF (
        LEN ( Minutes ) = 1,
        CONCATENATE ( "0", Minutes ),
        CONCATENATE ( "", Minutes )
    )
// Seconds with leading zeros
VAR S =
    IF (
        LEN ( Seconds ) = 1,
        CONCATENATE ( "0", Seconds ),
        CONCATENATE ( "", Seconds )
    )
// MilliSeconds with leading zeros
VAR MS =
    IF (
        LEN ( Milli ) = 1,
        CONCATENATE ( "0", Milli ),
        CONCATENATE ( "", Milli )
    )
// Now return hours, minutes and seconds with leading zeros in the proper format "hh:mm:ss"
RETURN
    CONCATENATE (H,CONCATENATE ( ":", CONCATENATE ( M, CONCATENATE ( ":", CONCATENATE(S, CONCATENATE(":", MS ) ) ) ) ) )

Creo que es correcto, pero analícenlo por favor. También adjuntando PBIX.

Hola davorgom,

Haga clic en Modelado-> Tiempo de datos-> Formato (hh: mm: ss tt)

Captura.PNG

Saludos,

jimmy tao

davorgom

En respuesta a v-yuta-msft

¿Hola, cómo estás? Gracias a tu respuesta.

Tengo que decir que no funciona. Si pongo ese formato, los datos aparecen en un «modo fecha» (12:00:00 am), no los registros de atletas con centésimas de segundo.

Creo que microsft tiene que mejorar esto, y tenemos que recolectar muchos votos. 😞

https://ideas.powerbi.com/forums/265200-power-bi-ideas/suggestions/15906970-milliseconds-as-format-o…

¿Tienes otra idea?

Gracias.

greg_deckler

En respuesta a davorgom

Dale un giro a esto. Voy a publicarlo en la Galería de medidas rápidas. Se basa en la publicación de blog con la que respondí anteriormente.

Duration Milliseconds = 
// Duration formatting 
// * Based on @konstatinos and @Greg_Deckler blog post 
// https://community.powerbi.com/t5/Community-Blog/Aggregating-Duration-Time/ba-p/22486 1/25/2016
// * Given a number of milliseconds, returns a format of "hh:mm:ss:000 format"
//
// We start with a duration in number of milliseconds
VAR Duration = SUM(Milliseconds[Milliseconds])
// There are 3,600,000 milliseconds in an hour
VAR Hours = INT ( Duration / 3600000)
// There are 60,000 milliseconds in a minute
VAR Minutes = INT ( MOD( Duration - ( Hours * 3600000 ),3600000 ) / 60000)
// There are 1000 milliseconds in a second  
VAR Seconds = INT (MOD ( MOD( Duration - ( Hours * 3600000 ) - (Minutes * 60000),60000 ), 60000 ) / 1000)
VAR Milli = ROUNDUP(MOD(MOD ( MOD( Duration - ( Hours * 3600000 ),3600000 ), 60000 ), 1000),0)
// These intermediate variables ensure that we have leading zero's concatenated onto single digits
// Hours with leading zeros
VAR H =
    IF ( LEN ( Hours ) = 1, 
        CONCATENATE ( "0", Hours ),
        CONCATENATE ( "", Hours )
      )
// Minutes with leading zeros
VAR M =
    IF (
        LEN ( Minutes ) = 1,
        CONCATENATE ( "0", Minutes ),
        CONCATENATE ( "", Minutes )
    )
// Seconds with leading zeros
VAR S =
    IF (
        LEN ( Seconds ) = 1,
        CONCATENATE ( "0", Seconds ),
        CONCATENATE ( "", Seconds )
    )
// MilliSeconds with leading zeros
VAR MS =
    IF (
        LEN ( Milli ) = 1,
        CONCATENATE ( "0", Milli ),
        CONCATENATE ( "", Milli )
    )
// Now return hours, minutes and seconds with leading zeros in the proper format "hh:mm:ss"
RETURN
    CONCATENATE (H,CONCATENATE ( ":", CONCATENATE ( M, CONCATENATE ( ":", CONCATENATE(S, CONCATENATE(":", MS ) ) ) ) ) )

Creo que es correcto, pero analícenlo por favor. También adjuntando PBIX.

greg_deckler

En respuesta a greg_deckler

Publiqué la solución en Quick Measure Gallery aquí:

https://community.powerbi.com/t5/Quick-Measures-Gallery/Milliseconds-Duration/mp/406698#M141

Hice un ajuste a los ceros iniciales durante milisegundos.

greg_deckler

https://community.powerbi.com/t5/Community-Blog/Aggregating-Duration-Time/ba-p/22486

Deja un comentario

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *