Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
JuanVR10
Frequent Visitor

Convertir columnas a filas en PowerQuery

Buenas tardes comunidad.

Espero me puedan ayudar con un problema en PowerQuery que no se si tiene solución.


Tengo una tabla con los registros Material - Clase de Movimiento y F.Contabilización

JuanVR10_0-1715287746549.png

Como el unico dato que se repite es Material, quiero ordenar mi tabla de la siguiente forma:

JuanVR10_1-1715287818092.png

de manera que en una fila quede el material y que se genere una nueva columna con las restantes 2 columnas.

Es decir, Clase de Mov, Fecha Contabilización, Clase de Mov2 y Fecha Contabilización.

 

He tratado de resolverlo con Pivot Columns y Unpivot Columns, pero no logro resolverlo.

Es posible realizar esto?

 

 

Gracias

Slds

Juan

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @JuanVR10 

 

Please try the following code:

let
    
    Source = Table.FromRecords({
        [Material = 40330098410, Clase de movimiento = 101, Fecha Contabilizacion = #date(2024, 9, 5)],
        [Material = 40330098410, Clase de movimiento = 601, Fecha Contabilizacion = #date(2024, 2, 1)]
    }),

    
    RemoveID = Table.RemoveColumns(Source, {"Material"}),

    
    #"Grouped Rows" = Table.Group(Source, "Material", {
        {"All Data", each Table.Pivot(
            Table.RemoveColumns(_, {"Material"}),
            List.Distinct(Table.TransformColumnTypes(_, {{"Fecha Contabilizacion", type text}}, "en-US")[Fecha Contabilizacion]),
            "Fecha Contabilizacion", "Clase de movimiento"
        )}
    }),

    #"Expanded Columns" = Table.ExpandTableColumn(#"Grouped Rows", "All Data", Table.ColumnNames(#"Grouped Rows"[All Data]{0}))
in
    #"Expanded Columns"

 

 

 

 

Best Regards,

Jayleny

 

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

1 REPLY 1
Anonymous
Not applicable

Hi @JuanVR10 

 

Please try the following code:

let
    
    Source = Table.FromRecords({
        [Material = 40330098410, Clase de movimiento = 101, Fecha Contabilizacion = #date(2024, 9, 5)],
        [Material = 40330098410, Clase de movimiento = 601, Fecha Contabilizacion = #date(2024, 2, 1)]
    }),

    
    RemoveID = Table.RemoveColumns(Source, {"Material"}),

    
    #"Grouped Rows" = Table.Group(Source, "Material", {
        {"All Data", each Table.Pivot(
            Table.RemoveColumns(_, {"Material"}),
            List.Distinct(Table.TransformColumnTypes(_, {{"Fecha Contabilizacion", type text}}, "en-US")[Fecha Contabilizacion]),
            "Fecha Contabilizacion", "Clase de movimiento"
        )}
    }),

    #"Expanded Columns" = Table.ExpandTableColumn(#"Grouped Rows", "All Data", Table.ColumnNames(#"Grouped Rows"[All Data]{0}))
in
    #"Expanded Columns"

 

 

 

 

Best Regards,

Jayleny

 

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

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors