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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
BalazsNy
Helper I
Helper I

Merge (concatenate) content of multiple cells into one cell

Hi All,

 

I have a table with comments for different Product IDs. Some Product ID can have several comments in multiple line.

I would like to group this table by product ID along with a comment column which includes all the comments merged into 1 cell. The aim is to avoid any duplicatd Product ID. I would like to separate each comment within the cells in new lines (see example below).

 

Screenshot 2024-11-21 074824.png

 

Thanks for all tips in advance.

1 ACCEPTED SOLUTION
shafiz_p
Super User
Super User

Hi @BalazsNy  Rather creating table, you need to create measure. In table inline will not work as you expect. 

Try below code to create measure:

MergedComments = 
VAR CurrentProductID = SELECTEDVALUE(YourTableName[Product ID])
RETURN
CONCATENATEX(
    FILTER(YourTableName, YourTableName[Product ID] = CurrentProductID),
    YourTableName[Comment],
    UNICHAR(13) & UNICHAR(10)
)

 

Create a table visual, place Product ID in the rows section and MergedComments in the value section. And you done. You will get the final as you desired. See image:

shafiz_p_0-1732172602026.png

 

 

Hope this helps!!

If this solved your problem, please mark this as a solution and a kudos!!

 

Best Regards,
Shahariar Hafiz

View solution in original post

3 REPLIES 3
shafiz_p
Super User
Super User

Hi @BalazsNy  Rather creating table, you need to create measure. In table inline will not work as you expect. 

Try below code to create measure:

MergedComments = 
VAR CurrentProductID = SELECTEDVALUE(YourTableName[Product ID])
RETURN
CONCATENATEX(
    FILTER(YourTableName, YourTableName[Product ID] = CurrentProductID),
    YourTableName[Comment],
    UNICHAR(13) & UNICHAR(10)
)

 

Create a table visual, place Product ID in the rows section and MergedComments in the value section. And you done. You will get the final as you desired. See image:

shafiz_p_0-1732172602026.png

 

 

Hope this helps!!

If this solved your problem, please mark this as a solution and a kudos!!

 

Best Regards,
Shahariar Hafiz

Thank you. It works perfectly.

danextian
Super User
Super User

Hi @BalazsNy 

 

Try these:

as a measure =
CONCATENATEX ( 'table', 'table'[comment], UNICHAR ( 10 ) )

as a calc column =
CONCATENATEX (
    ALLEXCEPT ( 'table', 'table'[product id] ),
    'table'[comment],
    UNICHAR ( 10 )
)




Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 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