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.
¿Alguna idea de por qué el siguiente lenguaje M no está produciendo los resultados deseados? Estoy tratando de agregar una nueva columna con un "1" para el registro 'wonum' con la marca de fecha y hora más reciente en el campo 'changedate' y un "0" para el no más reciente.
"Filtro de fecha añadido" ? Table.AddColumn("Eliminado otras columnas","Filtro de fecha", cada uno si [changedate] - List.Max(let currentwonum ? [wonum] en Table.SelectRows ("Eliminado otras columnas", cada [wonum] - currentwonum)[changedate]) entonces 1 más 0)
Mi solución fue modelada después de este post.
https://community.powerbi.com/t5/Desktop/Latest-Date-Filter/td-p/556579
Por @nwitstine y solución proporcionada por @v-jiascu-msft
Aquí están los datos de ejemplo y puede ver los resultados en la última columna. Debería haber algo de "1" ahí dentro.
wonum | Estado | changedate | changeby | memorándum | siteid | Filtro de fecha |
1001 | WAPPR | 9/21/2011 7:49 | SITTSJ | Null | Cg | 0 |
1001 | Aprox | 9/21/2011 7:57 | SITTSJ | Null | Cg | 0 |
1002 | WAPPR | 9/21/2011 7:59 | MERKELA | Null | Cg | 0 |
1002 | Aprox | 9/21/2011 8:12 | MERKELA | Null | Cg | 0 |
1005 | WAPPR | 9/21/2011 11:36 | MAXADMIN | Null | Cg | 0 |
1005 | Aprox | 9/21/2011 11:36 | MAXADMIN | Null | Cg | 0 |
1006 | WAPPR | 9/21/2011 11:41 | MAXADMIN | Null | Cg | 0 |
1006 | Aprox | 9/21/2011 11:41 | MAXADMIN | Null | Cg | 0 |
1007 | WAPPR | 9/21/2011 11:45 | MAXADMIN | Null | Cg | 0 |
1007 | Aprox | 9/21/2011 11:46 | MAXADMIN | Null | Cg | 0 |
1008 | WAPPR | 9/21/2011 11:47 | MAXADMIN | Null | Cg | 0 |
1008 | Aprox | 9/21/2011 11:47 | MAXADMIN | Null | Cg | 0 |
1009 | WAPPR | 9/21/2011 11:48 | MAXADMIN | Null | Cg | 0 |
1009 | Aprox | 9/21/2011 11:48 | MAXADMIN | Null | Cg | 0 |
1010 | WAPPR | 9/21/2011 11:48 | MAXADMIN | Null | Cg | 0 |
Solved! Go to Solution.
Gracias @v-alq-msft .
Pude hacer ese trabajo, pero impactó gravemente en la peformancia de la consulta.
Terminé yendo con esta solución.
https://community.powerbi.com/t5/Desktop/Group-by-last-date/td-p/326382
Hola, 4660042674
Según su descripción, creé datos para reproducir su escenario.
Puede agregar dos pasos como se indica a continuación.
= Table.AddColumn(#"Changed Type","Result", each let x=[wonum]in Table.Max(Table.SelectRows(#"Changed Type",each [wonum] = x),{"changedate"})[#"changedate"])
= Table.AddColumn(Custom1,"New",each if [changedate]=[Result] then 1 else 0)
Aquí están los códigos en el editor avanzado.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("nc9NCoMwEIbhq5SsBfOlxvzsQivFthZRoYJ4A3Hn/Rs33TRjQ1YzDDy8zDQxcA6Wsbdr285PkwvkggMnZQvjD309DP3dL+u2LH5cbmzOviygpDpUgojJPdZU3aN6Osr9MG0hjpkM5gB7LnfoRndt6hclk2BJJQtEyCSoyKSMkEH470tNJlWETIKGTOoImQLBE5LzBw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [wonum = _t, status = _t, changedate = _t, changeby = _t, memo = _t, siteid = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"wonum", Int64.Type}, {"status", type text}, {"changedate", type datetime}, {"changeby", type text}, {"memo", type text}, {"siteid", type text}}),
Custom1 = Table.AddColumn(#"Changed Type","Result", each let x=[wonum]in Table.Max(Table.SelectRows(#"Changed Type",each [wonum] = x),{"changedate"})[#"changedate"]),
Custom2 = Table.AddColumn(Custom1,"New",each if [changedate]=[Result] then 1 else 0)
in
Custom2
Resultado:
Saludos
Allan
Si este post ayuda,entonces por favor considere Aceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.
Gracias @v-alq-msft .
Pude hacer ese trabajo, pero impactó gravemente en la peformancia de la consulta.
Terminé yendo con esta solución.
https://community.powerbi.com/t5/Desktop/Group-by-last-date/td-p/326382
N.o 4660042674 Hola, tomo otra manera, pero el resultado es el deseado.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("nc9NCoMwEIbhq5SsBfOlxvzsQivFthZRoYJ4A3Hn/Rs33TRjQ1YzDDy8zDQxcA6Wsbdr285PkwvkggMnZQvjD309DP3dL+u2LH5cbmzOviygpDpUgojJPdZU3aN6Osr9MG0hjpkM5gB7LnfoRndt6hclk2BJJQtEyCSoyKSMkEH470tNJlWETIKGTOoImQLBE5LzBw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [wonum = _t, status = _t, changedate = _t, changeby = _t, memo = _t, siteid = _t]),
#"Changed Type with Locale" = Table.TransformColumnTypes(Source, {{"changedate", type datetime}}, "en-US"),
#"Added Custom" = Table.AddColumn(#"Changed Type with Locale", "Latest", each Table.SelectRows(#"Changed Type with Locale", let latest = List.Max(#"Changed Type with Locale"[changedate]) in each [changedate] = latest)),
#"Added Custom1" = Table.AddColumn(#"Added Custom", "Custom", each Table.Distinct( Table.SelectColumns([Latest],"changedate"))),
#"Removed Columns" = Table.RemoveColumns(#"Added Custom1",{"Latest"}),
#"Expanded Custom" = Table.ExpandTableColumn(#"Removed Columns", "Custom", {"changedate"}, {"Custom.changedate"}),
#"Added Custom2" = Table.AddColumn(#"Expanded Custom", "Custom", each if [changedate] = [Custom.changedate] then 1 else 0),
#"Removed Columns1" = Table.RemoveColumns(#"Added Custom2",{"Custom.changedate"})
in
#"Removed Columns1"
saludos
Gracias @Vvelarde ,
Desafortunadamente, esa no es la solución a la que estoy apuntando. La solución identifica la marca de tiempo más reciente de todo el conjunto de datos. Estoy buscando identificar la marca de tiempo más reciente para cada wonum. Las dos primeras filas de la captura de pantalla son un ejemplo. Si hacemos que esto funcione, la primera fila será "0" y la segunda fila será "1".
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 | |
1 | |
1 | |
1 | |
1 |
User | Count |
---|---|
2 | |
2 | |
2 | |
2 | |
1 |