Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
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
Solved! Go to Solution.
Hi @Anonymous ,
Try this:
Convert = CALCULATE(CONCATENATEX('Table','Table'[Name],","),ALLEXCEPT('Table','Table'[ID]))
Insert your table name for 'Table'.
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
Proud to be a Super User!
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 😀
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.
Hi @Anonymous ,
Try this:
Convert = CALCULATE(CONCATENATEX('Table','Table'[Name],","),ALLEXCEPT('Table','Table'[ID]))
Insert your table name for 'Table'.
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
Proud to be a Super User!
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:
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
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
76 | |
74 | |
57 | |
38 | |
33 |
User | Count |
---|---|
71 | |
65 | |
58 | |
50 | |
47 |