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

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

Reply
Anonymous
Not applicable

Convert list to csv based on other column

Hi there!

I have a scenario to convert list to csv grouped by ID column, please help!

Input:

ID   Name

1       A

1       B

1       C

2       D

3       E

3       F

 

Output:

ID   Name

1      A,B,C

2      D

3      E,F

1 ACCEPTED SOLUTION
Nathaniel_C
Community Champion
Community Champion

Hi @Anonymous ,

Try this:

Convert = CALCULATE(CONCATENATEX('Table','Table'[Name],","),ALLEXCEPT('Table','Table'[ID]))

Insert your table name for 'Table'. 

Change to comma.PNG


Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos are nice too.
Nathaniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Option 4: https://stackoverflow.com/questions/44058355/powerquery-how-can-i-concatenate-grouped-values

Option 5: GroupedRows = Table.Group(Source, {"ID"}, {"Name", each Text.Combine(_[Name], ",")})

 

Thanks guys! so many options to choose from 😀

Ashish_Mathur
Super User
Super User

Hi,

This M code in the Query Editor works

let
    Source = Excel.CurrentWorkbook(){[Name="Data"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", Int64.Type}, {"Name", type text}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"ID"}, {{"All Names", each Text.Combine(List.Distinct([Name]), ", "), type text}}),
    Joined = Table.Join(Source, "ID", #"Grouped Rows", "ID"),
    #"Removed Columns" = Table.RemoveColumns(Joined,{"Name"}),
    #"Removed Duplicates" = Table.Distinct(#"Removed Columns")
in
    #"Removed Duplicates"

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Nathaniel_C
Community Champion
Community Champion

Hi @Anonymous ,

Try this:

Convert = CALCULATE(CONCATENATEX('Table','Table'[Name],","),ALLEXCEPT('Table','Table'[ID]))

Insert your table name for 'Table'. 

Change to comma.PNG


Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos are nice too.
Nathaniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




lc_finance
Solution Sage
Solution Sage

Hi @Anonymous ,

 

 

You can obtain that by creating a calculated table and using CONCATENATEX.

The Power BI file with the proposed solution is available from here.

 

Below is the DAX formula for the calculated table (you can create a calculated table by going to Modeling -> New Table)

Output = ADDCOLUMNS(
    VALUES('Input'[ID])
    , "Name", 
    VAR currentID = [ID]
    RETURN CONCATENATEX(
        FILTER('Input', 'Input'[ID]=currentID)
        , [Name],",")
)

This formula does the following: first, it creates a row for each distinct ID value. So you will have one row for ID 1, one row for ID 2, and one row for ID 3. Then, for each row, it finds all the names in your initial table.

For example, for row ID 1, it will find three names: A, B, and C.

Finally, it concatenates these names and separates them with a comma.

 

Here is a screenshot:

Group by ID column.png

 

Hope this helps you! Do not hesitate if you have further questions.

 

LC

Interested in Power BI and DAX templates? Check out my blog at www.finance-bi.com

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.