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
JMSNYC
Helper III
Helper III

Agrupación en 1 valor y mantener otros campos en POWER QUERY

Hola.

Este es mi problema:

ProductoFecha de entrega cambiada enFecha de entrega antigua
A2/1/205/15/20
A3/1/205/20/20
A4/1/205/16/20

La salida que estoy buscando es

  • 1 hilera para el producto A, con
  • valor mínimo para la columna 2, y
  • SOLO valor respectivo para la columna 3, es decir, 5/15/2020.

Por lo tanto, Agrupar Min y luego Todas las filas no me dan la respuesta.

¿Alguna sugerencia? ¿Función tabla? ¿Función de lista?

Gracias por su ayuda

1 ACCEPTED SOLUTION
Jimmy801
Community Champion
Community Champion

Hola @JMSNYC

puede usar Table.Group y usar un Table.SelectRows en él.

Aquí un ejemplo completo. Echa un vistazo al paso "Filas agrupadas" que hace el truco

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUTLSN9Q3MgAyTPUNTUGsWB2IhDFCwsgAWcIESYcZWCIWAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Product = _t, #"Delivery Date Changed On" = _t, #"Old Delivery Date" = _t]),
    DateFormat = Table.TransformColumns
    (
        Source,
        {
            {
                "Delivery Date Changed On",
                each Date.From(_,"en-US"),
                type date
            },
            {
                "Old Delivery Date",
                each Date.From(_,"en-US"),
                type date
            }
        }
    ),
    #"Grouped Rows" = Table.Group(DateFormat, {"Product"}, {{"Min Date", each Table.SelectRows(_, (sel)=> sel[Delivery Date Changed On]= List.Min(_[Delivery Date Changed On])), type table [Product=text, Delivery Date Changed On=date, Old Delivery Date=date]}}),
    #"Expanded Min Date" = Table.ExpandTableColumn(#"Grouped Rows", "Min Date", {"Delivery Date Changed On", "Old Delivery Date"}, {"Delivery Date Changed On", "Old Delivery Date"})
in
    #"Expanded Min Date"

Copie pegue este código en el editor avanzado en una nueva consulta en blanco para ver cómo funciona la solución.

Si este post ayuda o resuelve su problema, márquelo como solución (para ayudar a otros usuarios a encontrar contenido útil y para reconocer el trabajo de los usuarios que le ayudaron)
Los Kudoes también son agradables.

Que te diviertas

Jimmy

View solution in original post

3 REPLIES 3
Jimmy801
Community Champion
Community Champion

Hola @JMSNYC

puede usar Table.Group y usar un Table.SelectRows en él.

Aquí un ejemplo completo. Echa un vistazo al paso "Filas agrupadas" que hace el truco

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUTLSN9Q3MgAyTPUNTUGsWB2IhDFCwsgAWcIESYcZWCIWAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Product = _t, #"Delivery Date Changed On" = _t, #"Old Delivery Date" = _t]),
    DateFormat = Table.TransformColumns
    (
        Source,
        {
            {
                "Delivery Date Changed On",
                each Date.From(_,"en-US"),
                type date
            },
            {
                "Old Delivery Date",
                each Date.From(_,"en-US"),
                type date
            }
        }
    ),
    #"Grouped Rows" = Table.Group(DateFormat, {"Product"}, {{"Min Date", each Table.SelectRows(_, (sel)=> sel[Delivery Date Changed On]= List.Min(_[Delivery Date Changed On])), type table [Product=text, Delivery Date Changed On=date, Old Delivery Date=date]}}),
    #"Expanded Min Date" = Table.ExpandTableColumn(#"Grouped Rows", "Min Date", {"Delivery Date Changed On", "Old Delivery Date"}, {"Delivery Date Changed On", "Old Delivery Date"})
in
    #"Expanded Min Date"

Copie pegue este código en el editor avanzado en una nueva consulta en blanco para ver cómo funciona la solución.

Si este post ayuda o resuelve su problema, márquelo como solución (para ayudar a otros usuarios a encontrar contenido útil y para reconocer el trabajo de los usuarios que le ayudaron)
Los Kudoes también son agradables.

Que te diviertas

Jimmy

Esto es increíble !! Funciona perfectamente. Muchas gracias y muchos elogios.

AllisonKennedy
Super User
Super User

@JMSNYC
He movido este post al foro de Power Query para que los expertos de Power Query lo vean. 🙂

Usted debe ser capaz de lograr esto duplicando su tabla. A continuación, utilice un grupo por nombre de producto: seleccione Fecha mínima. Por último, vuelva a combinar la tabla antigua en la nueva tabla utilizando las columnas Nombre de producto y Fecha como columnas coincidentes.

Esto no será muy eficiente, pero hace lo que usted ha pedido.

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

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.