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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Modifying table view in Power Query

I have the table in the below format

EmplIDSchoolDegreeMajor
123S1D1M1
123S2D2M2
123S3D3M3
456S1D1M1
456S2D2M2
456S3D3M3

 

I would want to change it to,

EmplIDSchool1Degree 1Major 1School2Degree 2Major 2School3Degree 3Major 3
123S1D1M1S2D2M2S3D3M3
456S1D1M1S2D2M2S3D3M3

 

 

Can someone suggest how we can achieve this in Power BI Desktop or using Query Editor?

1 ACCEPTED SOLUTION
slorin
Super User
Super User

Hi,

 

let
Source = YourSource,
Group = Table.Group(Source, {"EmplID"}, {{"Data", each Table.AddIndexColumn(_,"Index",1)}}),
Expand = Table.ExpandTableColumn(Group, "Data", {"School", "Degree", "Major", "Index"}, {"School", "Degree", "Major", "Index"}),
UnPivot = Table.UnpivotOtherColumns(Expand, {"EmplID", "Index"}, "Attribute", "Value"),
CombineColumns = Table.CombineColumns(Table.TransformColumnTypes(UnPivot, {{"Index", type text}}),{"Attribute", "Index"},Combiner.CombineTextByDelimiter(" ", QuoteStyle.None),"Attribute.1"),
Pivot = Table.Pivot(CombineColumns, List.Distinct(CombineColumns[Attribute.1]), "Attribute.1", "Value")
in
Pivot

 

Stéphane 

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Thank you @slorin. This helped!

slorin
Super User
Super User

Hi,

 

let
Source = YourSource,
Group = Table.Group(Source, {"EmplID"}, {{"Data", each Table.AddIndexColumn(_,"Index",1)}}),
Expand = Table.ExpandTableColumn(Group, "Data", {"School", "Degree", "Major", "Index"}, {"School", "Degree", "Major", "Index"}),
UnPivot = Table.UnpivotOtherColumns(Expand, {"EmplID", "Index"}, "Attribute", "Value"),
CombineColumns = Table.CombineColumns(Table.TransformColumnTypes(UnPivot, {{"Index", type text}}),{"Attribute", "Index"},Combiner.CombineTextByDelimiter(" ", QuoteStyle.None),"Attribute.1"),
Pivot = Table.Pivot(CombineColumns, List.Distinct(CombineColumns[Attribute.1]), "Attribute.1", "Value")
in
Pivot

 

Stéphane 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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