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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Whibley
New Member

Moving Rows into columns with Unique ID

Hello, I have a much larger set of data similar to below. I want to get it so Unique ID is in the row, and the Course Title is in the column. 

 

So from this:

TitleLearner IDLearner NameStatusDivision
Course 1ID1BobCompletedPayroll
Course 1ID2SarahCompletedHR
Course 1ID3AliceCompletedSales
Course 1ID4MarkIncompleteMarketing
Course 2ID1BobIncompletePayroll
Course 2ID2SarahIncompleteHR
Course 2ID3AliceIncompleteSales
Course 2ID4MarkCompletedMarketing
Course 3ID1BobCompletedPayroll
Course 3ID2SarahCompletedHR
Course 3ID3AliceIncompleteSales
Course 3ID4MarkCompletedMarketing

 

To this:

Learner IDLearner NameCourse 1Course 2Course 3Division
ID1BobCompletedIncompleteCompletedPayroll
ID2SarahCompletedIncompleteCompletedHR
ID3AliceCompletedIncompleteIncompleteSales
ID4MarkIncompleteCompletedCompletedMarketing

 

I've tried Pivot Columns but it doesnt merge the ID. 

 

Thanks in advance.

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

Hi @Whibley ,
Thanks for @amitchandak  reply.
Here some steps that I want to share, you can check them if they suitable for your requirement.
Here is my test data:

vheqmsft_0-1713936915467.png

Click "Transform data" and open power query
Select the Title column and select the pivot column in the Transform toolbar, then in the screen that opens select Status in the value column and select the Don't Aggregate option in the Aggregate Value function.Select the Title column and select the pivot column in the Transform toolbar, then in the screen that opens select Status in the value column and select the Don't Aggregate option in the Aggregate Value function.

vheqmsft_1-1713937217378.png

Final output

vheqmsft_2-1713937238168.png

You can also use this m code in advanced editor

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("lZCxDsIgEIZfpWHuIvgC2g420cZYt6bDWS9KpGCAmvj2QtKhQAe7/Lk7/v/ycW1LrtwKJDk5ImiJOqvKWVPD4N8aC3Y0rij5hxuuJOnylhRq1AazjZtXpde9ujkt1PAWaPHu6jN8tRIitVO/FTQ8o8DhknqZ053gPUbeBgSa1L51egL98o3sJ/80Q8vlYx6hEXyQWKCnCX2QCPFpgh+YE34a889/u4jP1t2erbg9WwnP/oTvfg==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"(blank)" = _t, #"(blank).1" = _t, #"(blank).2" = _t, #"(blank).3" = _t, #"(blank).4" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"(blank)", type text}, {"(blank).1", type text}, {"(blank).2", type text}, {"(blank).3", type text}, {"(blank).4", type text}}),
    #"Promoted Headers" = Table.PromoteHeaders(#"Changed Type", [PromoteAllScalars=true]),
    #"Changed Type1" = Table.TransformColumnTypes(#"Promoted Headers",{{"Title", type text}, {"Learner ID", type text}, {"Learner Name", type text}, {"Status", type text}, {"Division", type text}}),
    #"Pivoted Column" = Table.Pivot(#"Changed Type1", List.Distinct(#"Changed Type1"[Title]), "Title", "Status")
in
    #"Pivoted Column"

 

Best regards,

Albert He

 

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

4 REPLIES 4
v-heq-msft
Community Support
Community Support

Hi @Whibley ,
Thanks for @amitchandak  reply.
Here some steps that I want to share, you can check them if they suitable for your requirement.
Here is my test data:

vheqmsft_0-1713936915467.png

Click "Transform data" and open power query
Select the Title column and select the pivot column in the Transform toolbar, then in the screen that opens select Status in the value column and select the Don't Aggregate option in the Aggregate Value function.Select the Title column and select the pivot column in the Transform toolbar, then in the screen that opens select Status in the value column and select the Don't Aggregate option in the Aggregate Value function.

vheqmsft_1-1713937217378.png

Final output

vheqmsft_2-1713937238168.png

You can also use this m code in advanced editor

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("lZCxDsIgEIZfpWHuIvgC2g420cZYt6bDWS9KpGCAmvj2QtKhQAe7/Lk7/v/ycW1LrtwKJDk5ImiJOqvKWVPD4N8aC3Y0rij5hxuuJOnylhRq1AazjZtXpde9ujkt1PAWaPHu6jN8tRIitVO/FTQ8o8DhknqZ053gPUbeBgSa1L51egL98o3sJ/80Q8vlYx6hEXyQWKCnCX2QCPFpgh+YE34a889/u4jP1t2erbg9WwnP/oTvfg==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"(blank)" = _t, #"(blank).1" = _t, #"(blank).2" = _t, #"(blank).3" = _t, #"(blank).4" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"(blank)", type text}, {"(blank).1", type text}, {"(blank).2", type text}, {"(blank).3", type text}, {"(blank).4", type text}}),
    #"Promoted Headers" = Table.PromoteHeaders(#"Changed Type", [PromoteAllScalars=true]),
    #"Changed Type1" = Table.TransformColumnTypes(#"Promoted Headers",{{"Title", type text}, {"Learner ID", type text}, {"Learner Name", type text}, {"Status", type text}, {"Division", type text}}),
    #"Pivoted Column" = Table.Pivot(#"Changed Type1", List.Distinct(#"Changed Type1"[Title]), "Title", "Status")
in
    #"Pivoted Column"

 

Best regards,

Albert He

 

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

 

 

 

@v-heq-msft thanks, it doesnt work with "Status" as the completion dates are different so doesn't merge the IDs into one row. I had to add a custom column with the completion date which doesnt look as good. 

 

Is there a way round this? I would like to keep the completion dates as they are useful later on for analysis, but in this instance I would rather it just said complete.

amitchandak
Super User
Super User

@Whibley , Unpivot should help in this case

 

Unpivot Data(Power Query): https://youtu.be/2HjkBtxSM0g

 

Learn Power BI: Power Query Table.Unpivot, Table.UnpivotOtherColumns: https://youtu.be/0FEGEAz9UMw

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Unpivot seems to be putting data in rows rather than columns.

 

I want the row to group all courses in columns with the one unique ID.

 

To this:

Learner IDLearner NameCourse 1Course 2Course 3Division

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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