cancel
Showing results for 
Search instead for 
Did you mean: 
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
Vote for T-Shirt Design

Power BI T-Shirt Design Challenge 2023

Vote for your favorite t-shirt design now through March 28.

March 2023 Update3

Power BI March 2023 Update

Find out more about the March 2023 update.

March Events 2023A

March 2023 Events

Find out more about the online and in person events happening in March!

Top Solution Authors
Top Kudoed Authors