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.
Tengo una tabla de datos con el formato siguiente, y me gustaría poder cortar y cortar los datos para obtener el tiempo total en estado dependiendo de las segmentaciones de datos (Bassically Equip por rango de fechas).
- StateChangeId es una clave principal no duplicada.
- EquipmentId es la identificación duplicada de equipos específicos.
- StateId es un estado o estado duplicado (como roto, en ejecución, etc.)
- y CreatedDate es la Fecha/ Hora en que se creó el estado.
Obviamente, cuando un estado (registro) comienza, el estado (registro) anterior deja de dar duración.
inicialmente utilicé PowerQuery para agrupar por equipId y crear un índice por grupo que luego utilicé para traer los datos del registro anterior y calcular la duración. Esto funcionó excepto el principio donde no hay registro previo y el final donde los datos caen disparados del final del día o un estado dura varios días o más. Esto tampoco parece ser exacto al cortar.
Creo que esta mejor opción sería usar DAX y medidas que he estado investigando, pero que parece que no puedo acertar.
StateChangeId | EquipId | StateId | CreatedDate |
1 | 10 | 50 | 5/14/2022 10:42 |
2 | 13 | 55 | 5/14/2022 17:00 |
3 | 12 | 50 | 5/14/2022 17:00 |
4 | 13 | 50 | 5/14/2022 17:05 |
5 | 10 | 45 | 5/14/2022 17:11 |
6 | 10 | 50 | 5/14/2022 17:37 |
Si alguien pudiera señalarme en la dirección correcta, lo agradecería mucho.
@fmozingo - Para que pueda ver la solución similar en Power Query:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("dc5BCsAwCATArxTPgbhGK+QrIf//RqvQQEl72csOq2MQqBD4Dsuo0CoscoC7Cs0ySEK0KO0tvDOniBLysbGEro1dWAp7/tDtCpDi/PvUe3Oa8wI=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [StateChangeId = _t, EquipId = _t, StateId = _t, CreatedDate = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"StateChangeId", Int64.Type}, {"EquipId", Int64.Type}, {"StateId", Int64.Type}, {"CreatedDate", type datetime}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"EquipId"}, {{"Grouped", each _, type table [StateChangeId=nullable number, EquipId=nullable number, StateId=nullable number, CreatedDate=nullable datetime]}, {"MaxDate", each List.Max([CreatedDate]), type nullable datetime}, {"MinDate", each List.Min([CreatedDate]), type nullable datetime}}),
#"Expanded Grouped" = Table.ExpandTableColumn(#"Grouped Rows", "Grouped", {"StateChangeId", "StateId", "CreatedDate"}, {"StateChangeId", "StateId", "CreatedDate"}),
#"Added Custom" = Table.AddColumn(#"Expanded Grouped", "Total Minutes", each if [CreatedDate] = [MaxDate] then Duration.TotalMinutes([MaxDate]-[MinDate]) else 0),
#"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"MaxDate", "MinDate"})
in
#"Removed Columns"
Hola @fmozingo ,
Pruebe lo siguiente:
1) En su tabla, cree una columna calculada para obtener la fecha y hora anterior para la misma identificación del equipo.
2) A continuación, agregue otra columna calculada para calcular la duración.
3) Agregue columnas equipmentid y duration a una tabla visual y obtenga el resultado esperado
Atentamente
Rohit
Marque esta respuesta como la solución si resuelve su problema.
¡Aprecia sus felicitaciones! 😊
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
2 | |
2 | |
2 | |
2 | |
1 |