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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
AilleryO
Memorable Member
Memorable Member

Transpose and Group

Hi,

 

I'm struggling with a transposition/unpivoting problem.

My table looks like that :

Family

Product

F1

P1

F1

P2

F2

P3

F4

P4

F4

P5

F1

P6

F2

P7

 

and my required outcome would be :

F1

F2

F4

P1

P3

P4

P2

P7

P5

P6

P3

 

 

I managed to get all product values with a concatenate, but cannot find a way to have them in columns.

Any guess ?

Thanks for your help.

1 ACCEPTED SOLUTION
ImkeF
Community Champion
Community Champion

Hello @AilleryO ,
with a bit of tweaking the Group-code, you can achieve it like this:

let
  Source = Table.FromRows(
    Json.Document(
      Binary.Decompress(
        Binary.FromText(
          "i45WcjNU0lEKMFSK1YGxjSBsIxDbGMI2AbFNkNimSOrNkNSbK8XGAgA=", 
          BinaryEncoding.Base64
        ), 
        Compression.Deflate
      )
    ), 
    let
      _t = ((type nullable text) meta [Serialized.Text = true])
    in
      type table [Family = _t, Product = _t]
  ), 
  #"Changed Type" = Table.TransformColumnTypes(
    Source, 
    {{"Family", type text}, {"Product", type text}}
  ), 
  #"Grouped Rows" = Table.Group(#"Changed Type", {"Family"}, {{"Product", each _[Product]}}), 
  Custom1 = Table.FromColumns(#"Grouped Rows"[Product], #"Grouped Rows"[Family])
in
  Custom1



Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

View solution in original post

4 REPLIES 4
AilleryO
Memorable Member
Memorable Member

Thanks a lot that is beautiful 🙂

ImkeF
Community Champion
Community Champion

Hello @AilleryO ,
with a bit of tweaking the Group-code, you can achieve it like this:

let
  Source = Table.FromRows(
    Json.Document(
      Binary.Decompress(
        Binary.FromText(
          "i45WcjNU0lEKMFSK1YGxjSBsIxDbGMI2AbFNkNimSOrNkNSbK8XGAgA=", 
          BinaryEncoding.Base64
        ), 
        Compression.Deflate
      )
    ), 
    let
      _t = ((type nullable text) meta [Serialized.Text = true])
    in
      type table [Family = _t, Product = _t]
  ), 
  #"Changed Type" = Table.TransformColumnTypes(
    Source, 
    {{"Family", type text}, {"Product", type text}}
  ), 
  #"Grouped Rows" = Table.Group(#"Changed Type", {"Family"}, {{"Product", each _[Product]}}), 
  Custom1 = Table.FromColumns(#"Grouped Rows"[Product], #"Grouped Rows"[Family])
in
  Custom1



Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

@ImkeF, I love this. Simple and elegant.

 

@AilleryO Here's a method involving concatenating and transposing that may be more similar to your original idea:

let
  Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcjNU0lEKMFSK1YGxjSBsIxDbGMI2AbFNkNimSOrNkNSbK8XGAgA=",BinaryEncoding.Base64),Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table  [Family = _t, Product = _t]),
    #"Grouped Rows" = Table.Group(Source, {"Family"}, {{"Count", each Text.Combine([Product], "|")}}),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Grouped Rows", "Count", Splitter.SplitTextByDelimiter("|")),
    #"Transposed Table" = Table.Transpose(#"Split Column by Delimiter")
in
    #"Transposed Table"

 

Hi @AlexisOlson ,

 

Thanks for providing another solution that works perfectly as well.

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.