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
Baskar
Resident Rockstar
Resident Rockstar

Need idea in Group by

Hi all , 

 

Please help me on this case , I fight with this almost last 5 hours 🙂

 

Orginal Table look like this :

 

ID          Name

1            Pen

2            Chair

2            Table

3            Plug

3            Power

3            shocket

4           Board

4            Marker

4           Eraser

4           Clip

 

This data need to be tranlate to 

 

ID            New Column

1             Pen

2             Chair, table 

3             Plug, Power, shocket

4              Board, Marker, Eraser, Clip

 

2 ACCEPTED SOLUTIONS

Here is a DAX solution:

 

My queries

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUQpIzVOK1YlWMgKynTMSM4vgvJDEpJxUMM8YpC6nNB3ByS9PLYLzijPyk7NTS8B8EyDfKT+xKAXO800syoYqBnFdixKLkbjOOZkFSrGxAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [ID = _t, Name = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", Int64.Type}, {"Name", type text}})
in
    #"Changed Type"
let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlSK1YlWMgKTxmDSRCk2FgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [ID = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", Int64.Type}})
in
    #"Changed Type"

I used Enter Data queries, you could just use the same source, get rid of all columns except ID and then only get the distinct values from ID.

 

Relate your two tables on ID.

 

In IDs table, create the following column:

 

Names = CONCATENATEX(CALCULATETABLE(RELATEDTABLE('Grouping')),'Grouping'[Name],",")

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

View solution in original post

No problem! Learned a new DAX function, CONCATENATEX. Nifty!


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

View solution in original post

4 REPLIES 4
Baskar
Resident Rockstar
Resident Rockstar

Here is a DAX solution:

 

My queries

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUQpIzVOK1YlWMgKynTMSM4vgvJDEpJxUMM8YpC6nNB3ByS9PLYLzijPyk7NTS8B8EyDfKT+xKAXO800syoYqBnFdixKLkbjOOZkFSrGxAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [ID = _t, Name = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", Int64.Type}, {"Name", type text}})
in
    #"Changed Type"
let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlSK1YlWMgKTxmDSRCk2FgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [ID = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", Int64.Type}})
in
    #"Changed Type"

I used Enter Data queries, you could just use the same source, get rid of all columns except ID and then only get the distinct values from ID.

 

Relate your two tables on ID.

 

In IDs table, create the following column:

 

Names = CONCATENATEX(CALCULATETABLE(RELATEDTABLE('Grouping')),'Grouping'[Name],",")

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

Thanks @Greg_Deckler.

No problem! Learned a new DAX function, CONCATENATEX. Nifty!


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