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
maracles
Resolver II
Resolver II

Pivoting a column and aggregating text values - Power Query

I'm using Power Query in Excel and I'm trying to transform the data below in the image below. This image is a snipper of a larger dataset and shows information for 2 film titles. 

maracles_0-1605034245053.png

 

The data I receive is laid out incorrectly, I want to pivot the 'Fields' column so that it becomes my header row, which I can do using 'Pivot Column', my problem is that I want the 'Value' information to then be listed beneath this. 

For example, my first column would become Title, and the first two row values for this column should be The Rig and Good Luck To You, Leo Grande.

I do not know though how to get the transform to aggregate the data like this and list the values as individual rows under the pivoted column headers.

Advice would be much apprecaited. 

 

1 ACCEPTED SOLUTION
DavisBI
Solution Specialist
Solution Specialist

Hi, @maracles ,

 

Suppose we have the following table:

 

DavisBI_0-1606702764238.png

First, you can filter the null value and then transpose it :

    #"Filtered Rows" = Table.SelectRows(#"Changed Type", each ([Fields] <> null)),
    #"Transposed Table" = Table.Transpose(#"Filtered Rows")

 

Secondly, reference this query twice as "Sheet(2)" and "Sheet(3)" respectively.

 

20201130101739.png

 

Then you can append this two query after "remove columns" and "Use first row as Header".

 

20201130101748.png

 

Finally, you can get the result you want:

 

20201130101756.png

 

Mark this answer as a solution if this helps, thanks!

View solution in original post

1 REPLY 1
DavisBI
Solution Specialist
Solution Specialist

Hi, @maracles ,

 

Suppose we have the following table:

 

DavisBI_0-1606702764238.png

First, you can filter the null value and then transpose it :

    #"Filtered Rows" = Table.SelectRows(#"Changed Type", each ([Fields] <> null)),
    #"Transposed Table" = Table.Transpose(#"Filtered Rows")

 

Secondly, reference this query twice as "Sheet(2)" and "Sheet(3)" respectively.

 

20201130101739.png

 

Then you can append this two query after "remove columns" and "Use first row as Header".

 

20201130101748.png

 

Finally, you can get the result you want:

 

20201130101756.png

 

Mark this answer as a solution if this helps, thanks!

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.