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
Pick
Helper II
Helper II

Crear una nueva tabla para mostrar el tiempo entre pedidos

Hola

Tengo una tabla con una lista de pedidos con fecha de inicio y hora de finalización. Necesito producir otra tabla para mostrar el tiempo en minutos desde el final de la última orden hasta el estrato de la siguiente orden. Las tablas antes y después se muestran a continuación. Cualquier ayuda es apreciada.

Antes

SonOrganizational_UnitOrder_NoProduct_CodeSemanaStart_TimeEnd_TimeMinutos
Sono2cabello132458609118496102/01/2020 15:0702/01/2020 19:21254.25
Sono2cabello132458619118496102/01/2020 19:5202/01/2020 23:10198
Sono2cabello1324764567836033103/01/2020 00:0403/01/2020 02:24139.75
Sono2cabello1324764667836033103/01/2020 02:1903/01/2020 05:21

181.75

Después

SonOrganizational_UnitPrevious_Order_NoPreviois_Product_CodeNext_Order_NoNext_Product_CodePrevious_Order_End_TimeNext_Order_Start_TimeMinutos
Sono2cabello13245860911849613245861911849602/01/2020 19:2102/01/2020 19:5221
Sono2cabello132458619118496132476456783603302/01/2020 23:1003/01/2020 00:0454
Sono2cabello1324764567836033132476466783603303/01/2020 02:2403/01/2020 02:19-5
Sono2cabello132476466783603313247849911851603/01/2020 05:2103/01/2020 06:2776

saludos

Ian

3 REPLIES 3
dax
Community Support
Community Support

Hola @Pick ,

Podrías consultar mi muestra para más detalles.

Saludos
Zoe Zhi

Si este post ayuda, entonces considera Aceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.

@dax que funcionó gracias

BA_Pete
Super User
Super User

Hola @Pick ,

En Power Query, ordene [start_time] y [end_time] para que se muestren correctamente en orden cronológico.

Agregue una columna de índice a partir de 0, llámela [index0] o similar.

Agregue la columna de índice a partir de 1, llámela [index1] o similar.

Combine (unir) la tabla sobre sí misma utilizando [index0] como la primera columna de combinación y [index1] como la segunda.

Expanda las columnas [time_start] y [time_end] y cámbieles el nombre a [prev_time_end], etc.

Editar:

Aquí está el código de Power Query para seguir los pasos que tomé:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("fZAxCsMwDEWvUjyHRPq2ZEsn6N4xZOjYpYHef6id0kINziAkHtLjo3UNt/25I0zhen+8auOIJEWpjsZckmmDtQgL8QICXViccofM0bYgaYaEbRqJ+VRsLvhHiM4tDFsZWbMmqaPmEpVi/Grjz0HklDoERzrubc7DvNWs52Y4W4fk8wkufJi3Nw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Sono = _t, Organizational_Unit = _t, Order_No = _t, Product_Code = _t, Week = _t, Start_Time = _t, End_Time = _t, Minutes = _t]),
    chgAllTypes = Table.TransformColumnTypes(Source,{{"Sono", type text}, {"Organizational_Unit", type text}, {"Order_No", type text}, {"Product_Code", type text}, {"Week", type text}, {"Start_Time", type datetime}, {"End_Time", type datetime}, {"Minutes", type number}}),
    sortDateTimes = Table.Sort(chgAllTypes,{{"Start_Time", Order.Ascending}, {"End_Time", Order.Ascending}}),
    addIndex0 = Table.AddIndexColumn(sortDateTimes, "Index0", 0, 1),
    addIndex1 = Table.AddIndexColumn(addIndex0, "Index1", 1, 1),
    mergeOnMyself = Table.NestedJoin(addIndex1, {"Index0"}, addIndex1, {"Index1"}, "Added Index1", JoinKind.LeftOuter),
    expandPrevTimes = Table.ExpandTableColumn(mergeOnMyself, "Added Index1", {"Start_Time", "End_Time"}, {"Prev_Start_Time", "Prev_End_Time"})
in
    expandPrevTimes

En Power Query, vaya a Nuevo origen > Consulta en blanco y, a continuación, en Editor avanzado pegue mi código sobre el código predeterminado.

Solo he expandido las columnas DateTime en mi ejemplo, el principio es el mismo para cualquier otra columna que desee mostrar el valor anterior de.



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




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 Kudoed Authors