Forum Discussion
Anonymous
8 years agoNot 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
| Column1 | Column2 |
| 1 | Apple |
| 2 | Apple |
| 3 | Apple |
| 4 | Apple |
| 5 | Carrot |
| 6 | Carrot |
| 7 | Carrot |
I want the Output like below
| Column1 | Column2 | Column3 |
| 1 | Apple | 1,2,3,4 |
| 2 | Apple | 1,2,3,4, |
| 3 | Apple | 1,2,3,4, |
| 4 | Apple | 1,2,3,4, |
| 5 | Carrot | 5,6,7 |
| 6 | Carrot | 5,6,7 |
| 7 | Carrot | 5,6,7 |
Thanks.
Paruchuri
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
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:
5 Replies
- Vvelarde
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
- MarcelBeug
Community Champion
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:
- AnonymousNot applicable
I found the answer.
CALCULATE(CONCATENATEX(Tablename,Tablename[column-1],","),FILTER(Tablename,Tablename[Column-2]=EARLIER(Tablename[Column-1])))