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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
mandix
Regular Visitor

Trying to convert rows to comma separated values where a bridge table is involved.

Hi all, 

 

I have two dimension tables joined via a bridge table. I want to concatenate all possible values using a comma and present them against the other dimension primary key values.

 

I have a .pbix file but it's not allowing me to attach for reference. To help explain here's comes some preparation. 

 

Preparation:

1. CustQ =

 

let
    KeyedIn = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUfLNzE5VitWJVjICchxz0opSU8BcYyDXO7EEImcC5LiWZCTmKcXGAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [CustKey = _t, CustName = _t]),
    #"Changed Type" = Table.TransformColumnTypes(KeyedIn,{{"CustKey", Int64.Type}})
in
    #"Changed Type"

 

2. CustQ Data =

CustKeyCustName

1Mike
2Alfred
3Kate
4Ethan

3. CatQ =

 

let
    KeyedIn = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUfJNzElVitWJVjICctxSc2FcYyA3oCg/LbW4ODM/LzFHKTYWAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [CatKey = _t, Cat = _t]),
    #"Changed Type" = Table.TransformColumnTypes(KeyedIn,{{"CatKey", Int64.Type}})
in
    #"Changed Type"

 

4. CatQ Data = 

CatKeyCat

1Male
2Female
3Professional

5. BridgeCustCatQ =

 

let
    KeyedIn = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSAeJYnWglIzjLGMgyArNAssZwWQjLBKIuFgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [CustKey = _t, CatKey = _t]),
    #"Changed Type" = Table.TransformColumnTypes(KeyedIn,{{"CustKey", Int64.Type}, {"CatKey", Int64.Type}})
in
    #"Changed Type"

 

6. BridgeCustCatQ Data = 

CustKeyCatKey

11
21
32
13
23
41

Here's the basic model. 

mandix_0-1734900135627.png

What I have achieved so far is as per below screen shot. 

mandix_1-1734900226990.png

Below is the code for the right hand table. 

 

LISTAGG_CatKey = SUMMARIZECOLUMNS(
    CustQ[CustKey],
    TREATAS(VALUES(CustQ[CustKey]), BridgeCustCatQ[CatKey]),
    "CatKeys", CONCATENATEX(VALUES(BridgeCustCatQ[CatKey]), BridgeCustCatQ[CatKey], ", ")
)

 

Issue:

But ideally what I need is highlighted below (contents of the screen shot, overall, are incorrect as far as "Cat" values are concerned). 

mandix_2-1734900387050.png

Below is the code I have attempted for the actual category names (but currently returning all category names - which is not expected). 

 

Table 2 = SUMMARIZECOLUMNS(
    CustQ[CustKey],
    TREATAS (VALUES(CatQ[CatKey]), BridgeCustCatQ[CatKey]),
    "Cat", CONCATENATEX(VALUES(CatQ[Cat]), CatQ[Cat], ", ")
)

 

I tried concatenating the category keys. However, the following code is also not giving an expected result. 

 

EVALUATE
SUMMARIZECOLUMNS(
    CustQ[CustKey],
    TREATAS (VALUES(CustQ[CustKey]), BridgeCustCatQ[CatKey]),
    "CatKeys", CONCATENATEX(VALUES(CatQ[CatKey]), CatQ[CatKey], ", ")
)

 

mandix_3-1734900772607.png

Not sure, what I am doing wrong. Can someone please help? 

Thank you very much. 

Regards, 

Manjo.

 

 

 

 

 

 

 

1 ACCEPTED SOLUTION
4 REPLIES 4
mandix
Regular Visitor

mandix_0-1734983947400.pngmandix_1-1734984032069.png

 

LISTAGG_Cat = SUMMARIZECOLUMNS(
    CustQ[CustKey],
    "Cat", CONCATENATEX(VALUES(CatQ[Cat]), CatQ[Cat], ", ")
)
mandix
Regular Visitor

The forum suggested a post (it's not being shown now) where it was mentioned that bridge tables need bidirectional support. I changed it and I am getting the expected results now. 

Hi @mandix ,

Thank you for reaching out to us and for updating us on your progress. It's glad to hear that you were able to identify and resolve the issue on your own. Could you please mark your post as Answered since it has been resolved by yourself?

vyiruanmsft_0-1734938341575.png

If you have any further questions or need additional assistance in the future, please don't hesitate to reach out. Your proactive approach and willingness to share your solution are greatly appreciated and can be very helpful to other community members facing similar challenges. Thank you.

Best Regards

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

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.