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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
ErinKlomp
New Member

Pivot some columns

Hi all, another question from a first time user.

I finally have all my data, but now as a final step, I want to pivot some of my colums. I have 4 colums, where I want to pivot two of the colums (and sort the rest accordingly)

evaluatieperiodeidspecialismegegevenantwoordwaardevraagcode
59141AA1resp_1_Alg1
59141AA3resp_1_Alg2
59141AA2resp1_Alg3
59142BB4resp_1_Alg1
59142BB2resp_1_Alg2
59142BB0resp1_Alg3

I want to achieve this:

evaluatieperiodeidspecialismeresp_1_Alg1resp_1_Alg2resp1_Alg3
59141AA132
59142BB420

 

There are about 800 different vraagcodes.

 

Hoping someone can help me achieve this!

1 ACCEPTED SOLUTION
dufoq3
Super User
Super User

Hi @ErinKlomp, if you want Power Query solution:

 

Result

dufoq3_0-1721395276782.png

dufoq3_1-1721395285736.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMrU0NDFU0lFydAQSIEZRanFBvGG8Y066oVKsDpoCYxQFRpgKjKAKwPLGcHmQsJMTkDDBYQNcgREOG+AKDNBsiAUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [evaluatieperiodeid = _t, specialisme = _t, gegevenantwoordwaarde = _t, vraagcode = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"gegevenantwoordwaarde", Int64.Type}}),
    #"Pivoted Column" = Table.Pivot(#"Changed Type", List.Distinct(#"Changed Type"[vraagcode]), "vraagcode", "gegevenantwoordwaarde")
in
    #"Pivoted Column"

Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

View solution in original post

2 REPLIES 2
dufoq3
Super User
Super User

Hi @ErinKlomp, if you want Power Query solution:

 

Result

dufoq3_0-1721395276782.png

dufoq3_1-1721395285736.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMrU0NDFU0lFydAQSIEZRanFBvGG8Y066oVKsDpoCYxQFRpgKjKAKwPLGcHmQsJMTkDDBYQNcgREOG+AKDNBsiAUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [evaluatieperiodeid = _t, specialisme = _t, gegevenantwoordwaarde = _t, vraagcode = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"gegevenantwoordwaarde", Int64.Type}}),
    #"Pivoted Column" = Table.Pivot(#"Changed Type", List.Distinct(#"Changed Type"[vraagcode]), "vraagcode", "gegevenantwoordwaarde")
in
    #"Pivoted Column"

Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

Joe_Barry
Super User
Super User

Hi @ErinKlomp 

 

Try using a Matrix visual

 

Put the first two columns in the row section and the last column in column section and the 3rd column in the value section.

 

That should do it for you.

 

Hope this helps

Joe

 

 




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Learn about the Star Schema, it will solve many issues in Power BI!

Date tables help! Learn more



LinkedIn
Let's connect on LinkedIn


Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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

Top Solution Authors