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
kmoxley
Frequent Visitor

Unpivoting to keep the key id unique

My Data looks like this

ID Grade SubjectScore1 Score2

1   2           Math   #             #

1  2             ELA   #             #

2  3            Math  #             #

2  3              ELA   #             #

 

I need it to look like this

ID Grade ELA.Score1 MAth.Score1

1     2          #                  #

2      3         #                  #

1 REPLY 1
MarcelBeug
Community Champion
Community Champion

Try this query:

 

let
    Source = MyData,
    #"Removed Columns" = Table.RemoveColumns(Source,{"Score2"}),
    #"Added Suffix" = Table.TransformColumns(#"Removed Columns", {{"Subject", each Text.From(_, "en-US") & ".Score1", type text}}),
    #"Pivoted Column" = Table.Pivot(#"Added Suffix", List.Distinct(#"Added Suffix"[Subject]), "Subject", "Score1")
in
    #"Pivoted Column"
Specializing in Power Query Formula Language (M)

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.