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
jorgeslzr
Frequent Visitor

Filtrar la consulta de edición

Hola, tengo un origen de datos que tiene una columna con Store_ID, fecha y estado:

STORE_IDFechaEstado
A101/01No activado
A101/01Activado
B101/01Activado
C201/02No activado

Como puede ver, puede haber dos estados para el mismo STORE_ID en la misma FECHA... Dado que para mis medidas hago DISTINCTCOUNT en tiendas, es inútil para mí cargar row1 (A1 - No Activado) en mi .pbix porque también lo tengo activado ese día. PERO si sólo no está activado ese día (última fila, por ejemplo), quiero mantenerlo en mi tabla.

¿Hay alguna manera de filtrar esta tabla en POWER QUERY EDITOR para que mis datos .pbix sean mucho más pequeños y lo hagan más rápido? Quiero hacer esto porque mis datos son enormes y podría filtrar eso.

¡Gracias!

1 ACCEPTED SOLUTION
v-yiruan-msft
Community Support
Community Support

Hola @jorgeslzr ,

Puede editar los códigos aplicados en el Editor avanzado para lograrlo:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcjRU0lEyMjAy0DfUBzH98ksUEpNLMssSS1JTlGJ1MFU4osg64ZV1NkLIGmGaHgsA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [STORE_ID = _t, DATE = _t, STATUS = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"STORE_ID", type text}, {"DATE", type date}, {"STATUS", type text}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"DATE", "STORE_ID"}, {{"Count", each Table.RowCount(Table.Distinct(_)), Int64.Type}, {"Details", each _, type table [STORE_ID=nullable text, DATE=nullable date, STATUS=nullable text]}}),
    #"Expanded Details" = Table.ExpandTableColumn(#"Grouped Rows", "Details", {"STATUS"}, {"Details.STATUS"}),
    #"Filtered Rows" = Table.SelectRows(#"Expanded Details", each ([Details.STATUS] = "Not activated") and ([Count] = 1))
in
    #"Filtered Rows"

advanced editor.JPG

También puede consultar el siguiente blog para lograrlo:

Agrupación en Power Query; Obtener el último elemento en cada grupo

Saludos

Rena

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

View solution in original post

2 REPLIES 2
v-yiruan-msft
Community Support
Community Support

Hola @jorgeslzr ,

Puede editar los códigos aplicados en el Editor avanzado para lograrlo:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcjRU0lEyMjAy0DfUBzH98ksUEpNLMssSS1JTlGJ1MFU4osg64ZV1NkLIGmGaHgsA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [STORE_ID = _t, DATE = _t, STATUS = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"STORE_ID", type text}, {"DATE", type date}, {"STATUS", type text}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"DATE", "STORE_ID"}, {{"Count", each Table.RowCount(Table.Distinct(_)), Int64.Type}, {"Details", each _, type table [STORE_ID=nullable text, DATE=nullable date, STATUS=nullable text]}}),
    #"Expanded Details" = Table.ExpandTableColumn(#"Grouped Rows", "Details", {"STATUS"}, {"Details.STATUS"}),
    #"Filtered Rows" = Table.SelectRows(#"Expanded Details", each ([Details.STATUS] = "Not activated") and ([Count] = 1))
in
    #"Filtered Rows"

advanced editor.JPG

También puede consultar el siguiente blog para lograrlo:

Agrupación en Power Query; Obtener el último elemento en cada grupo

Saludos

Rena

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
themistoklis
Community Champion
Community Champion

@jorgeslzr

En función de la descripción que enviaste, supongo que siempre obtienes el último estado basado en el campo de fecha (que debe tener tiempo también).

En la consulta de energía debe hacer alguna clasificación y, a continuación, seleccionar los valores más recientes.

Puede ver los siguientes 2 enlaces:

https://blog.crossjoin.co.uk/2015/05/11/nested-calculations-in-power-query/

https://www.excelguru.ca/blog/2018/06/14/ranking-method-choices-in-power-query/

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.