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

Transpor colunas com o mesmo nome em linhas

Boa tarde, pessoal!

 

Estou tentando transpor algumas colunas de uma base em linhas, no entando, existem "duplicatas" entre elas já na base original. O PWBI atribui um valor númerico ao final do nome da coluna para diferenciação, mas uma vez que transpuz as colunas, precisaria que elas tivessem a mesma formatação de nome. (Exemplo anexo)

 

Alguma dica?

 

mathlucena_0-1669843618549.png

 

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

Hi @mathlucena ,

 

Based on your description, I have created a simple sample:

 

First, duplicate your transposed table:

vjianbolimsft_0-1669860501991.png

Then keep the columns you need and remove others:

vjianbolimsft_1-1669860576052.png

Append the tables:

vjianbolimsft_2-1669860617456.png

Here is the M code:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSlTSAeJYnWilJCArCcxKBrKSwawUICsFzEoFslLBLKiOWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, ID.1 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", type text}, {"ID.1", type text}}),
    #"Transposed Table" = Table.Transpose(#"Changed Type"),
    #"Removed Columns" = Table.RemoveColumns(#"Transposed Table",{"Column6"}),
    #"Appended Query" = Table.Combine({#"Removed Columns", #"Table (2)"})
in
    #"Appended Query"

Final output:

vjianbolimsft_3-1669860702562.png

 

Best Regards,

Jianbo Li

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
v-jianboli-msft
Community Support
Community Support

Hi @mathlucena ,

 

Based on your description, I have created a simple sample:

 

First, duplicate your transposed table:

vjianbolimsft_0-1669860501991.png

Then keep the columns you need and remove others:

vjianbolimsft_1-1669860576052.png

Append the tables:

vjianbolimsft_2-1669860617456.png

Here is the M code:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSlTSAeJYnWilJCArCcxKBrKSwawUICsFzEoFslLBLKiOWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, ID.1 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", type text}, {"ID.1", type text}}),
    #"Transposed Table" = Table.Transpose(#"Changed Type"),
    #"Removed Columns" = Table.RemoveColumns(#"Transposed Table",{"Column6"}),
    #"Appended Query" = Table.Combine({#"Removed Columns", #"Table (2)"})
in
    #"Appended Query"

Final output:

vjianbolimsft_3-1669860702562.png

 

Best Regards,

Jianbo Li

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

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.

Top Solution Authors