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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
maxs3
Frequent Visitor

After Pivoting a Table I Need to Condense Rows

Hello,

 

I pivoted a table, and it resulted in many "NULL" values in columns, I am trying to condense/aggregate (not sure right word here) to a single ROW instead of 3 ROWS.

 

What I have

GroupNameValue1Value2Value3
1141NULLNULL
11NULL415NULL
11NULLNULL152
12156NULLNULL
12NULL332NULL
12NULLNULL121.6
21156NULLNULL
21NULL156NULL
21NULLNULL156
22156NULLNULL
22NULL156NULL
22NULLNULL156

 

What I am trying to get

GroupNameValue1Value2Value3
1141415152
12156332121.6
21156156156
22156156156

 

Thank you!

M

2 ACCEPTED SOLUTIONS
selimovd
Super User
Super User

Hey @maxs3 ,

 

you can do that in Power Query.

Go to the Transform tab and use the "Group by" function:

selimovd_0-1624375980680.png

 

Then you can group by "Group" and "Name" and sum by the value columns:

selimovd_1-1624375998846.png

 

Afterwards, the result is like you wanted to be:

selimovd_2-1624376054942.png

 

Check my solution in the advanced editor:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSAWMTEOEX6uMDo2J1EJJQcRNDUzyyUMrQ1AguawTmm+Ew2QghbmxshEcWZrKRoZ4ZWN4IajN2s41Q3YWkCIsskiKYLG5XG6G6C4vJWFwNMjkWAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Group = _t, Name = _t, Value1 = _t, Value2 = _t, Value3 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Group", Int64.Type}, {"Name", Int64.Type}, {"Value1", type number}, {"Value2", type number}, {"Value3", type number}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Group", "Name"}, {{"Value1", each List.Sum([Value1]), type nullable text}, {"Value2", each List.Sum([Value2]), type nullable text}, {"Value3", each List.Sum([Value3]), type nullable text}})
in
    #"Grouped Rows"

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

View solution in original post

Anonymous
Not applicable

HI @maxs3,

You can enter to query editor to replace all 'NULL' string to the null value, then you can use the 'fill down' feature to expand these three field values.
After these steps, you only need to add a filter on your table to keep records which three fields not equal to blank.
Regards,
Xiaoxin Sheng

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

HI @maxs3,

You can enter to query editor to replace all 'NULL' string to the null value, then you can use the 'fill down' feature to expand these three field values.
After these steps, you only need to add a filter on your table to keep records which three fields not equal to blank.
Regards,
Xiaoxin Sheng

selimovd
Super User
Super User

Hey @maxs3 ,

 

you can do that in Power Query.

Go to the Transform tab and use the "Group by" function:

selimovd_0-1624375980680.png

 

Then you can group by "Group" and "Name" and sum by the value columns:

selimovd_1-1624375998846.png

 

Afterwards, the result is like you wanted to be:

selimovd_2-1624376054942.png

 

Check my solution in the advanced editor:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSAWMTEOEX6uMDo2J1EJJQcRNDUzyyUMrQ1AguawTmm+Ew2QghbmxshEcWZrKRoZ4ZWN4IajN2s41Q3YWkCIsskiKYLG5XG6G6C4vJWFwNMjkWAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Group = _t, Name = _t, Value1 = _t, Value2 = _t, Value3 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Group", Int64.Type}, {"Name", Int64.Type}, {"Value1", type number}, {"Value2", type number}, {"Value3", type number}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Group", "Name"}, {{"Value1", each List.Sum([Value1]), type nullable text}, {"Value2", each List.Sum([Value2]), type nullable text}, {"Value3", each List.Sum([Value3]), type nullable text}})
in
    #"Grouped Rows"

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 
HotChilli
Super User
Super User

In Power Query, select the first 2 columns and do a 'Group By', put 3 aggregations of MIN (1 on each value column).

Good luck.

Helpful resources

Announcements
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.