cancel
Showing results for
Did you mean:
New Member

## How to Aggregate data

Hello,

Im trying to aggregate data as follow:

Current data format:

ID   Name
1       A
1       B
1       C
2       D
2       E
3       F

Expected result:

ID     Name
1        A;B;C
2         D;E
3           F

Do you know how to build this step in my query?

Best regards,

2 ACCEPTED SOLUTIONS

Accepted Solutions
Microsoft

## Re: How to Aggregate data

Hi @Klaimand,

Based on my test, you could refer to below formula:

Create a new table:

`New Table = SUMMARIZE('Table1','Table1'[ID],"Name",CONCATENATEX('Table1','Table1'[Name],","))`

Result:

Regards,

Daniel He

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Super User IV

## Re: How to Aggregate data

Hi,

This M code works

```let
Source = Excel.CurrentWorkbook(){[Name="Data"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", Int64.Type}, {"Name", type text}}),
Combine = Table.Group(#"Changed Type", {"ID"}, {{"All Names", each Text.Combine(List.Distinct([Name]), "; "), type text}})
in
Combine```

Regards,
Ashish Mathur
http://www.ashishmathur.com
3 REPLIES 3
New Contributor

## Re: How to Aggregate data

@Klaimand

Create a Measure and add the following formula:

`Measure = CONCATENATEX ( VALUES ( 'Table'[Text] ), 'Table'[Text], ", " )`

Microsoft

## Re: How to Aggregate data

Hi @Klaimand,

Based on my test, you could refer to below formula:

Create a new table:

`New Table = SUMMARIZE('Table1','Table1'[ID],"Name",CONCATENATEX('Table1','Table1'[Name],","))`

Result:

Regards,

Daniel He

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Super User IV

## Re: How to Aggregate data

Hi,

This M code works

```let
Source = Excel.CurrentWorkbook(){[Name="Data"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", Int64.Type}, {"Name", type text}}),
Combine = Table.Group(#"Changed Type", {"ID"}, {{"All Names", each Text.Combine(List.Distinct([Name]), "; "), type text}})
in
Combine```

Regards,
Ashish Mathur
http://www.ashishmathur.com

Announcements

#### Meet the 2020 Season 1 Power BI Super Users!

It’s the start of a new Super User season! Learn all about the new Super Users and brand-new tiered recognition system.

#### Super User Challenge: Can You Solve These?

We're celebrating the start of the New Super User season with our first ever Super User 'Can You Solve These?' challenge.

#### Power BI Desktop Update - February 2020

We are super excited for our update this month, as we are releasing two of our top community requests!