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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
hwoehrle
Frequent Visitor

Unpivoting Group of Columns by start of columnnames

Hi,

 

i'm trying to unpivot a table that has some grouped columns:

hwoehrle_0-1647885302268.png

 

The goal woud be to have the blue datasetunpivoted to the green.

Here is the sample data:

 

Since the columnname-endings may change, a flexilble solution like "group all columns with name S1* and unpivot them..." would be fantastic 🙂

 

Thanks for any advice and hint!

Best regards,

Heiko

1 ACCEPTED SOLUTION
Anonymous
Not applicable

unpivot group recordfromlist.pngtry this

 

 

let
    Source = Excel.Workbook(File.Contents("C:\Users\sprmn\OneDrive\Documents\Power BI Desktop\SplitColumns.xlsx"), null, true),
    Org_Table = Source{[Item="Org",Kind="Table"]}[Data],
    #"Changed Type" = Table.TransformColumnTypes(Org_Table,{{"Basis", type text}, {"Description", type text}, {"S1.Typ", type text}, {"S1.H.UUID", type text}, {"S1.n", Int64.Type}, {"S1.E.UUID", type text}, {"S2.Typ", type text}, {"S2.H.UUID", type text}, {"S2.n", Int64.Type}, {"S2.E.UUID", type text}, {"S3.Typ", type text}, {"S3.H.UUID", type text}, {"S3.n", Int64.Type}, {"S3.E.UUID", type text}}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Basis", "Description"}, "Attribute", "Value"),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Unpivoted Other Columns", "Attribute", Splitter.SplitTextByEachDelimiter({"."}, QuoteStyle.Csv, false), {"Part", "Attribute.2"}),
    #"Grouped Rows" = Table.Group(#"Split Column by Delimiter", {"Basis", "Description", "Part"}, {{"part", each Record.FromList([Value],[#"Attribute.2"])}}),
    #"Expanded part" = Table.ExpandRecordColumn(#"Grouped Rows", "part", {"Typ", "H.UUID", "n", "E.UUID"}, {"Typ", "H.UUID", "n", "E.UUID"})
in
    #"Expanded part"

 

 

I used the first "." as part separator S1, S2, etc.
If the real situation is different, you have to adapt to the logic

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

unpivot group recordfromlist.pngtry this

 

 

let
    Source = Excel.Workbook(File.Contents("C:\Users\sprmn\OneDrive\Documents\Power BI Desktop\SplitColumns.xlsx"), null, true),
    Org_Table = Source{[Item="Org",Kind="Table"]}[Data],
    #"Changed Type" = Table.TransformColumnTypes(Org_Table,{{"Basis", type text}, {"Description", type text}, {"S1.Typ", type text}, {"S1.H.UUID", type text}, {"S1.n", Int64.Type}, {"S1.E.UUID", type text}, {"S2.Typ", type text}, {"S2.H.UUID", type text}, {"S2.n", Int64.Type}, {"S2.E.UUID", type text}, {"S3.Typ", type text}, {"S3.H.UUID", type text}, {"S3.n", Int64.Type}, {"S3.E.UUID", type text}}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Basis", "Description"}, "Attribute", "Value"),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Unpivoted Other Columns", "Attribute", Splitter.SplitTextByEachDelimiter({"."}, QuoteStyle.Csv, false), {"Part", "Attribute.2"}),
    #"Grouped Rows" = Table.Group(#"Split Column by Delimiter", {"Basis", "Description", "Part"}, {{"part", each Record.FromList([Value],[#"Attribute.2"])}}),
    #"Expanded part" = Table.ExpandRecordColumn(#"Grouped Rows", "part", {"Typ", "H.UUID", "n", "E.UUID"}, {"Typ", "H.UUID", "n", "E.UUID"})
in
    #"Expanded part"

 

 

I used the first "." as part separator S1, S2, etc.
If the real situation is different, you have to adapt to the logic

KNP
Super User
Super User

If the columns that you DON'T want to unpivot are constant, select those, right click and choose 'Unpivot Other Columns'

 

KNP_0-1647887467836.png

 

Have I solved your problem?
Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;).
xOIEmaj

If you found this post helpful, please give Kudos.
It gives me a sense of instant gratification and, if you give me Kudos enough times, magical unicorns will appear on your screen.
If you find my signature vaguely amusing, please give Kudos.
image
fabric-SUbadge
Proud to be a Super User!

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.