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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
alai9
New Member

show different combinations for unique IDs

Hello,

Is it possible to convert this table in PowerQuery:

IDType

1000

A
1000B
1000C
1001C
1002C

 

to this view:

IDType
1000A B C
1001C
1002C

 

NOTE: there can be more or less than 3 values for Types (depends on user input).

 

Thanks in Advance!

2 ACCEPTED SOLUTIONS
edhans
Super User
Super User

Yes @alai9 - see this code.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQwMFDSUXJUitWBc5yQOc4wjiEyxwjCiQUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, Type = _t]),
    #"Grouped Rows" = Table.Group(Source, {"ID"}, {{"AllRows", each _, type table [ID=nullable text, Type=nullable text]}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each Text.Combine([AllRows][Type], " ")),
    #"Removed Other Columns" = Table.SelectColumns(#"Added Custom",{"ID", "Custom"})
in
    #"Removed Other Columns"

It turns this:

edhans_0-1602611661744.png

into this:

edhans_1-1602611680670.png

 

How to use M code provided in a blank query:
1) In Power Query, select New Source, then Blank Query
2) On the Home ribbon, select "Advanced Editor" button
3) Remove everything you see, then paste the M code I've given you in that box.
4) Press Done
5) See this article if you need help using this M code in your model.

 

 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

View solution in original post

v-alq-msft
Community Support
Community Support

Hi, @alai9 

 

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

Table:

a1.png

 

You may add a new step with following m codes.

= Table.Group(#"Changed Type", {"ID"}, {{"Type", each Text.Combine(_[Type]," "),type text}})

 

Result:

a2.png

 

Best Regards

Allan

 

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-alq-msft
Community Support
Community Support

Hi, @alai9 

 

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

Table:

a1.png

 

You may add a new step with following m codes.

= Table.Group(#"Changed Type", {"ID"}, {{"Type", each Text.Combine(_[Type]," "),type text}})

 

Result:

a2.png

 

Best Regards

Allan

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

edhans
Super User
Super User

Yes @alai9 - see this code.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQwMFDSUXJUitWBc5yQOc4wjiEyxwjCiQUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, Type = _t]),
    #"Grouped Rows" = Table.Group(Source, {"ID"}, {{"AllRows", each _, type table [ID=nullable text, Type=nullable text]}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each Text.Combine([AllRows][Type], " ")),
    #"Removed Other Columns" = Table.SelectColumns(#"Added Custom",{"ID", "Custom"})
in
    #"Removed Other Columns"

It turns this:

edhans_0-1602611661744.png

into this:

edhans_1-1602611680670.png

 

How to use M code provided in a blank query:
1) In Power Query, select New Source, then Blank Query
2) On the Home ribbon, select "Advanced Editor" button
3) Remove everything you see, then paste the M code I've given you in that box.
4) Press Done
5) See this article if you need help using this M code in your model.

 

 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors