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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Anonymous
Not applicable

Concatenate 2 columns

Hello Community,

 

I have 2 Columns one column is with numbers and second column contains unique text values. I want to add comma separate to first column based on second column. 

 

I'm very new to power bi and just learning it.

 

Table-1

Column1Column2
1Apple
2Apple
3Apple
4Apple
5Carrot
6Carrot
7Carrot

 

I want the Output like below

 

Column1Column2Column3
1Apple1,2,3,4
2Apple1,2,3,4,
3Apple1,2,3,4,
4Apple1,2,3,4,
5Carrot5,6,7
6Carrot5,6,7
7Carrot5,6,7

 

Thanks.

Paruchuri

2 ACCEPTED SOLUTIONS
Vvelarde
Community Champion
Community Champion

@Anonymous

 

Hi, try with this calculated column

 

Column =
CONCATENATEX (
    SUMMARIZE (
        FILTER ( Table2, Table2[Fruit] = EARLIER ( Table2[Fruit] ) ),
        Table2[ID]
    );
    Table2[ID],
    ","
)

 

Regards

 

Victor

Lima - Peru




Lima - Peru

View solution in original post

A Power Query solution:

 

let
    Source = Table1,
    #"Grouped Rows" = Table.Group(Source, {"Column2"}, {{"Column3", each Text.Combine([Column1],","), type text}, {"AllRows", each _, type table}}),
    #"Expanded AllRows" = Table.ExpandTableColumn(#"Grouped Rows", "AllRows", {"Column1"}, {"Column1"}),
    #"Changed Type" = Table.TransformColumnTypes(#"Expanded AllRows",{{"Column1", type text}}),
    #"Removed Other Columns" = Table.SelectColumns(#"Changed Type",{"Column1", "Column2", "Column3"})
in
    #"Removed Other Columns"

 

This is how the code was created:

Specializing in Power Query Formula Language (M)

View solution in original post

5 REPLIES 5
Vvelarde
Community Champion
Community Champion

@Anonymous

 

Hi, try with this calculated column

 

Column =
CONCATENATEX (
    SUMMARIZE (
        FILTER ( Table2, Table2[Fruit] = EARLIER ( Table2[Fruit] ) ),
        Table2[ID]
    );
    Table2[ID],
    ","
)

 

Regards

 

Victor

Lima - Peru




Lima - Peru

A Power Query solution:

 

let
    Source = Table1,
    #"Grouped Rows" = Table.Group(Source, {"Column2"}, {{"Column3", each Text.Combine([Column1],","), type text}, {"AllRows", each _, type table}}),
    #"Expanded AllRows" = Table.ExpandTableColumn(#"Grouped Rows", "AllRows", {"Column1"}, {"Column1"}),
    #"Changed Type" = Table.TransformColumnTypes(#"Expanded AllRows",{{"Column1", type text}}),
    #"Removed Other Columns" = Table.SelectColumns(#"Changed Type",{"Column1", "Column2", "Column3"})
in
    #"Removed Other Columns"

 

This is how the code was created:

Specializing in Power Query Formula Language (M)
Anonymous
Not applicable

I found the answer.

 

CALCULATE(CONCATENATEX(Tablename,Tablename[column-1],","),FILTER(Tablename,Tablename[Column-2]=EARLIER(Tablename[Column-1])))

Congratulations.

 

Typically there are more answers possible, though,

 

I hopy you don't mean our answers were incorrect?

Specializing in Power Query Formula Language (M)
Anonymous
Not applicable

I don't mean your answer is incorrect. We can do that way as well. Thanks for the solution.

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors