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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
West
New Member

Transformar filas con valor repetido a columna. Power Query

Buenas tardes:

Tengo una tabla denomida "Tabla Actual" cuya columna "nº" tiene valores repetidos y estos valores quería traspasarlos a columnas según la figura que adjunto.

Agradería ayuda para hacer la transformación usando power query en Power BI.

tabla conversion a columnas de filas repetidas.jpg

 

Muchas gracias.

West.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @West ,

If I understand correctly, the issue is that you want to convert rows with duplicate values to columns. Please try the following methods and check if they can solve your problem:

1.Create the simple table.

vjiewumsft_0-1707207106581.png

2.Click on Transform data.

 

3.Select the table and choose advanced editor.

vjiewumsft_1-1707207121850.png

4.Enter the following statement.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUTI0ABLGSrE6EK4pEJvAeWZwOSOwuA6QhvHMwBjEMwaL6yhZgHkmYD1Ag8E8U7A4TKUpij5TFH0gniXEvlgA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [N = _t, BI = _t, VA = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"N", Int64.Type}, {"BI", Int64.Type}, {"VA", Int64.Type}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"N"}, {{"Count", each _, type table [N=nullable number, BI=nullable number, VA=nullable number]}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each Table.AddIndexColumn([Count],"Index",1)),
    #"Expanded Custom" = Table.ExpandTableColumn(#"Added Custom", "Custom", {"BI", "VA", "Index"}, {"BI", "VA", "Index"}),
    #"Removed Columns" = Table.RemoveColumns(#"Expanded Custom",{"Count"}),
    #"Unpivoted Only Selected Columns" = Table.Unpivot(#"Removed Columns", {"BI", "VA"}, "Attribute", "Value"),
    #"Merged Columns" = Table.CombineColumns(Table.TransformColumnTypes(#"Unpivoted Only Selected Columns", {{"Index", type text}}, "en-US"),{ "Attribute","Index"},Combiner.CombineTextByDelimiter("", QuoteStyle.None),"Merged"),
    #"Pivoted Column" = Table.Pivot(#"Merged Columns", List.Distinct(#"Merged Columns"[Merged]), "Merged", "Value", List.Sum)
in
    #"Pivoted Column"

 

5.The result is shown below.

vjiewumsft_2-1707207130506.png

 

Best Regards,

Wisdom Wu

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @West ,

If I understand correctly, the issue is that you want to convert rows with duplicate values to columns. Please try the following methods and check if they can solve your problem:

1.Create the simple table.

vjiewumsft_0-1707207106581.png

2.Click on Transform data.

 

3.Select the table and choose advanced editor.

vjiewumsft_1-1707207121850.png

4.Enter the following statement.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUTI0ABLGSrE6EK4pEJvAeWZwOSOwuA6QhvHMwBjEMwaL6yhZgHkmYD1Ag8E8U7A4TKUpij5TFH0gniXEvlgA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [N = _t, BI = _t, VA = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"N", Int64.Type}, {"BI", Int64.Type}, {"VA", Int64.Type}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"N"}, {{"Count", each _, type table [N=nullable number, BI=nullable number, VA=nullable number]}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each Table.AddIndexColumn([Count],"Index",1)),
    #"Expanded Custom" = Table.ExpandTableColumn(#"Added Custom", "Custom", {"BI", "VA", "Index"}, {"BI", "VA", "Index"}),
    #"Removed Columns" = Table.RemoveColumns(#"Expanded Custom",{"Count"}),
    #"Unpivoted Only Selected Columns" = Table.Unpivot(#"Removed Columns", {"BI", "VA"}, "Attribute", "Value"),
    #"Merged Columns" = Table.CombineColumns(Table.TransformColumnTypes(#"Unpivoted Only Selected Columns", {{"Index", type text}}, "en-US"),{ "Attribute","Index"},Combiner.CombineTextByDelimiter("", QuoteStyle.None),"Merged"),
    #"Pivoted Column" = Table.Pivot(#"Merged Columns", List.Distinct(#"Merged Columns"[Merged]), "Merged", "Value", List.Sum)
in
    #"Pivoted Column"

 

5.The result is shown below.

vjiewumsft_2-1707207130506.png

 

Best Regards,

Wisdom Wu

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.