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
Anonymous
Not applicable

Change rows to colums

Hello everyone,

 

i have a table with 3 colums:

A   B   C

A - serial number
B - number 1 or 2
C - serial number

Well my task is:

A   B(1)  B(2)
     C       C

Thank you 


1 ACCEPTED SOLUTION

Hello @Anonymous 

 

the Text.Combine has to be used as pivot-function of your third column. Here an example

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcjRU0lFyAhHOhkqxOjABI5CAEUTACF2FEbKKWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [A = _t, B = _t, C = _t]),
    #"Pivoted Column" = Table.Pivot(Source, List.Distinct(Source[B]), "B", "C", each Text.Combine(_,",")
)
in
    #"Pivoted Column"

Jimmy801_0-1609408157772.png

Jimmy801_1-1609408174297.png

Copy paste this code to the advanced editor in a new blank query to see how the solution works.

If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

Have fun und guten Rutsch 🙂

Jimmy

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

TY!!! - Wünsche Dir auch

Anonymous
Not applicable

Bild1.png

 

maybe this explains better 🙂

Hello @Anonymous 

 

the Text.Combine has to be used as pivot-function of your third column. Here an example

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcjRU0lFyAhHOhkqxOjABI5CAEUTACF2FEbKKWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [A = _t, B = _t, C = _t]),
    #"Pivoted Column" = Table.Pivot(Source, List.Distinct(Source[B]), "B", "C", each Text.Combine(_,",")
)
in
    #"Pivoted Column"

Jimmy801_0-1609408157772.png

Jimmy801_1-1609408174297.png

Copy paste this code to the advanced editor in a new blank query to see how the solution works.

If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

Have fun und guten Rutsch 🙂

Jimmy

Jimmy801
Community Champion
Community Champion

Hello @Anonymous 

 

your specification doesn't tell to much. However you can get the result by applying a pivoting-function on your 1or2 column using then SN1 as value column. But as I don't know to treat your value column, I simply applied a sum-function. This might not work in your scenario. Here the code

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WUtJRMgTjWB0wxwiMY2MB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [SN = _t, #"1or2" = _t, SN1 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"SN", Int64.Type}, {"1or2", Int64.Type}, {"SN1", Int64.Type}}),
    #"Pivoted Column" = Table.Pivot(Table.TransformColumnTypes(#"Changed Type", {{"1or2", type text}}, "de-DE"), List.Distinct(Table.TransformColumnTypes(#"Changed Type", {{"1or2", type text}}, "de-DE")[#"1or2"]), "1or2", "SN1", List.Sum),
    #"Renamed Columns" = Table.RenameColumns(#"Pivoted Column",{{"1", "1or2 - 1"}, {"2", "1or2 - 2"}})
in
    #"Renamed Columns"

Jimmy801_0-1609403460775.png

Jimmy801_1-1609403471535.png

 

Copy paste this code to the advanced editor in a new blank query to see how the solution works. 

If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

Have fun

Jimmy

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
Top Kudoed Authors