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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

Diferencia de tiempo

Hola a todos

Necesita su ayuda para asesorar sobre cómo calcular el número de horas/minutos de Inicio y Fin del trabajo para John y Lucy.

Aquí está el enlace al archivo pbix como referencia.
Archivo PBIX

¡Aprecia tu opinión!

Capture.JPG

saludos

Hidayat

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hola @edhans ,

He intentado este mquery, pero el resultado muestra un error en la columna de tiempo.

Se ha encontrado una solución para mi problema mediante Pivot en PowerQuery para transponer filas en columnas.

View solution in original post

4 REPLIES 4
v-lid-msft
Community Support
Community Support

Hola @Yatz86 ,

Podemos usar las dos medidas siguientes con la columna Autor en la tabla visual para satisfacer sus requisitos:

Hours =
DATEDIFF (
    CALCULATE ( MIN ( 'Table'[DateTime] ), 'Table'[Timeln_Out] = "Shift Start" ),
    CALCULATE ( MAX ( 'Table'[DateTime] ), 'Table'[Timeln_Out] = "Shift End" ),
    HOUR
)

Minutes =
DATEDIFF (
    CALCULATE ( MIN ( 'Table'[DateTime] ), 'Table'[Timeln_Out] = "Shift Start" ),
    CALCULATE ( MAX ( 'Table'[DateTime] ), 'Table'[Timeln_Out] = "Shift End" ),
    MINUTE
)


Saludos

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
edhans
Super User
Super User

A ver si esto funciona. Devuelve el total de minutos, que puede dividir por 60 si desea obtener horas y horas fraccionarias.

Este es el resultado final:

2020-04-28 09_52_31-Untitled - Power Query Editor.png

Pegue el código M siguiente en una consulta en blanco para ver lo que hice:

1) En Power Query, seleccione Nuevo origen y, a continuación, Consulta en blanco
2) En la cinta inicio, seleccione el botón "Editor avanzado"
3) Retire todo lo que ve, luego pegue el código M que le he dado en ese cuadro.
4) Pulse Hecho

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtE3stA3MlAwNLAyMlPSUfLKz8gDUsEZmWklCsEliUUlIF5JflGqgiOQZWihFKuDpMvEytgCXZdrXgqKHiMDFD2WVgYGQFGf0uRKHBY5gTQZolpkjkUXskVgPUZKsbEA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [DateTime = _t, Author.FirstName = _t, TimeIn_Out = _t, Store = _t, Id = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"DateTime", type datetime}, {"Author.FirstName", type text}, {"TimeIn_Out", type text}, {"Store", type text}, {"Id", Int64.Type}}),
    #"Added End time" = Table.ExpandListColumn(Table.AddColumn(#"Changed Type", "End Time",
        each
            let varName = [Author.FirstName]
        in 
            Table.SelectRows(#"Changed Type", each [Author.FirstName] = varName and [TimeIn_Out] = "Shift End")[DateTime]),"End Time"),
    #"Changed Type1" = Table.TransformColumnTypes(#"Added End time",{{"DateTime", type datetime}, {"End Time", type datetime}}),
    #"Added Duration in Minutes" = Table.AddColumn(#"Changed Type1", "Duration", each Duration.TotalMinutes([End Time] - [DateTime])),
    #"Changed Type2" = Table.TransformColumnTypes(#"Added Duration in Minutes",{{"Duration", Int64.Type}}),
    #"Filtered Rows" = Table.SelectRows(#"Changed Type2", each ([TimeIn_Out] = "Shift Start"))
in
    #"Filtered Rows"


Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting
Anonymous
Not applicable

Hola @edhans ,

He intentado este mquery, pero el resultado muestra un error en la columna de tiempo.

Se ha encontrado una solución para mi problema mediante Pivot en PowerQuery para transponer filas en columnas.

camargos88
Community Champion
Community Champion

Hola @Yatz86 ,

Marque este archivo como un ejemplo: Descargar PBIX

He desorientado los valores de tiempo y calculado los minutos.

Si lo considera como una solución, marque como una solución y felicitaciones.

Ricardo



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors