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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Concatenate / Combine values based on another column

Kia Ora

 

I would like to know if there is a way of achieving the following: I have a table that has codes and a key that identifies related codes. In the example below all one's are related, all the two's and so on.

 

I need an output that combines the codes when they are related by a key - see the desired outcome column.

 

As seen in the example below there can be multiple codes that are the same for the key. I just need a combined outcome of each distinct code for each key.

 

I also need the outcome to shoew in the same format for each row. i.e. for key one each row must be ABC123 / BCD234 and not a mix of ABC123 / BCD234 & BCD234 / ABC123.

 

I would eb very gratful if anyone know if this is possible.

 

CodeKey Desired Outcome
ABC1231 ABC123 / BCD234
ABC1231 ABC123 / BCD234
BCD2341 ABC123 / BCD234
BCD2341 ABC123 / BCD234
CDE3452 CDE345 / DEF456
CDE3452 CDE345 / DEF456
DEF4562 CDE345 / DEF456
DEF4562 CDE345 / DEF456
EFG5673 EFG567 / FGH678
EFG5673 EFG567 / FGH678
FGH6783 EFG567 / FGH678
FGH6783 EFG567 / FGH678
1 ACCEPTED SOLUTION
Zubair_Muhammad
Community Champion
Community Champion

@Anonymous

 

You can use this as calculated column

 

Column =
CONCATENATEX (
    CALCULATETABLE (
        VALUES ( TableName[Code] ),
        ALLEXCEPT ( TableName, TableName[Key] )
    ),
    [Code],
    " / ",
    [Code], ASC
)

View solution in original post

1 REPLY 1
Zubair_Muhammad
Community Champion
Community Champion

@Anonymous

 

You can use this as calculated column

 

Column =
CONCATENATEX (
    CALCULATETABLE (
        VALUES ( TableName[Code] ),
        ALLEXCEPT ( TableName, TableName[Key] )
    ),
    [Code],
    " / ",
    [Code], ASC
)

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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