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
Chen2023
New Member

Group multiple columns to one row per ID

Hi all,

I would like to get your help in issue that I'm faced with.

I have this table:

 

Chen2023_0-1664623833426.png

 



I would like to group all these colums to one row per Computer ID (please find the desired result below):

 

Chen2023_1-1664623848616.png

 


Is it possible to perform? what should I do in order to get this?

Thanks in advance!

1 ACCEPTED SOLUTION
v-yalanwu-msft
Community Support
Community Support

Hi, @Chen2023 ;

Try it.

1.unpivot [February],[March],[April] columns:

vyalanwumsft_0-1664872007738.png

2.select the [Attribute] column the pivot it.

vyalanwumsft_1-1664872058646.png

The final show:

vyalanwumsft_2-1664872079194.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUXJMLsksSwUy/EpzcmBUrA5EEioWnJOaWpCZl45DGko5FaUmZqfkl+eB5Y3wmW2EEENVgyaJqgYkaYzFOUh6jfEZbILiSEzNJjg1xwIA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Computer ID" = _t, February = _t, March = _t, April = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Computer ID", Int64.Type}, {"February", type text}, {"March", type text}, {"April", type text}}),
    #"Replaced Value" = Table.ReplaceValue(#"Changed Type","Null",null,Replacer.ReplaceValue,{"February", "March", "April"}),
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Replaced Value", {"Computer ID"}, "Attribute", "Value"),
    #"Pivoted Column" = Table.Pivot(#"Unpivoted Columns", List.Distinct(#"Unpivoted Columns"[Attribute]), "Attribute", "Value")
in
    #"Pivoted Column"


Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-yalanwu-msft
Community Support
Community Support

Hi, @Chen2023 ;

Try it.

1.unpivot [February],[March],[April] columns:

vyalanwumsft_0-1664872007738.png

2.select the [Attribute] column the pivot it.

vyalanwumsft_1-1664872058646.png

The final show:

vyalanwumsft_2-1664872079194.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUXJMLsksSwUy/EpzcmBUrA5EEioWnJOaWpCZl45DGko5FaUmZqfkl+eB5Y3wmW2EEENVgyaJqgYkaYzFOUh6jfEZbILiSEzNJjg1xwIA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Computer ID" = _t, February = _t, March = _t, April = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Computer ID", Int64.Type}, {"February", type text}, {"March", type text}, {"April", type text}}),
    #"Replaced Value" = Table.ReplaceValue(#"Changed Type","Null",null,Replacer.ReplaceValue,{"February", "March", "April"}),
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Replaced Value", {"Computer ID"}, "Attribute", "Value"),
    #"Pivoted Column" = Table.Pivot(#"Unpivoted Columns", List.Distinct(#"Unpivoted Columns"[Attribute]), "Attribute", "Value")
in
    #"Pivoted Column"


Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Greg_Deckler
Super User
Super User

@Chen2023 Do a Group By step by ID and use a Maximum aggregator for each of your columns. You need to use the Advanced options of Group by.

Greg_Deckler_0-1664627401508.png

 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.

Top Solution Authors
Top Kudoed Authors