Forum Discussion
Agrupar columnas mediante Power Query con varias condiciones
- 4 years ago
Hola, @MP-iCONN
Puede modificar la parte de recuento en el código original.
Así:
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCvc3sjQwNFLSUTIyMLTUNTDTNbIEciA4VgerAgsgxxSMsSkw1zUAcQwNIAQOJcYgWUMIgaokrzQnByQOxjh0g1wAFlCKjQUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"WO ID" = _t, #"Day of WKE Lab Start Time" = _t, #"Avg Emp Count" = _t, #"Max Emp Count" = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"WO ID", type text}, {"Day of WKE Lab Start Time", type date}, {"Avg Emp Count", Int64.Type}, {"Max Emp Count", Int64.Type}}), #"Grouped Rows" = Table.Group(#"Changed Type", {"WO ID"}, {{"Avg", each List.Average([Avg Emp Count]), type nullable number}, {"Max", each List.Max([Max Emp Count]), type nullable number}, {"Count", each Table.RowCount(Table.SelectRows(_,(x)=>x[Day of WKE Lab Start Time]<>null)), Int64.Type}}) in #"Grouped Rows"Table.SelectRows(_,(x)=>x[Day of WKE Lab Start Time]<>null)¿Respondí a su pregunta? Por favor, marque mi respuesta como solución. Muchas gracias.
Si no, por favor siéntase libre de preguntarme.
Saludos
Equipo de apoyo a la comunidad _ Janey
En realidad, para hacerlo más fácil, creo que encontré una manera de hacer esto, pero ahora solo estoy atrapado en esto. Cómo obtener un recuento de "Día de la hora de inicio del laboratorio WKE" y no incluir el null.
Tomé estos datos:
| DONDE ID | Día de la hora de inicio del laboratorio WKE | Recuento de Emp promedio | Recuento máximo de emp |
| WO29012 | 2019-06-29 | 9 | 9 |
| WO29012 | 2019-06-28 | 5 | 5 |
| WO29012 | 2019-07-02 | 10 | 10 |
| WO29012 | 2019-07-03 | 11 | 11 |
| WO29012 | nulo | 1 | 1 |
| WO29012 | 2019-07-08 | 2 | 2 |
Luego agrupado así para obtener el conteo (que no estoy seguro de que esté haciendo bien con la parte de conteo):
Entonces conseguí esto. Definitivamente debería tener un conteo de 5 para el "Día de la Hora de Inicio del Laboratorio WKE"
| DONDE ID | Avg | Máximo | Contar |
| WO29012 | 6.33333333333333 | 11 | 6 |
Hola, @MP-iCONN
Puede modificar la parte de recuento en el código original.
Así:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCvc3sjQwNFLSUTIyMLTUNTDTNbIEciA4VgerAgsgxxSMsSkw1zUAcQwNIAQOJcYgWUMIgaokrzQnByQOxjh0g1wAFlCKjQUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"WO ID" = _t, #"Day of WKE Lab Start Time" = _t, #"Avg Emp Count" = _t, #"Max Emp Count" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"WO ID", type text}, {"Day of WKE Lab Start Time", type date}, {"Avg Emp Count", Int64.Type}, {"Max Emp Count", Int64.Type}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"WO ID"}, {{"Avg", each List.Average([Avg Emp Count]), type nullable number}, {"Max", each List.Max([Max Emp Count]), type nullable number}, {"Count", each Table.RowCount(Table.SelectRows(_,(x)=>x[Day of WKE Lab Start Time]<>null)), Int64.Type}})
in
#"Grouped Rows"Table.SelectRows(_,(x)=>x[Day of WKE Lab Start Time]<>null)
¿Respondí a su pregunta? Por favor, marque mi respuesta como solución. Muchas gracias.
Si no, por favor siéntase libre de preguntarme.
Saludos
Equipo de apoyo a la comunidad _ Janey