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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Butterfly
New Member

Make to make a column with list of related values?

anonymised data

I have table of "Elements", that is related to another entity of "Categories" with a many to many relationship: 

Butterfly_0-1669631926423.png

from that I have a table visual for "Elements": 

Butterfly_1-1669624191587.png

I want to add another column, that lists all the categories this element belongs to. 

If I add the column with the category name, it looks, as expected, like this: 

Butterfly_3-1669624501453.png

But I aim for it to look like this: 

Butterfly_2-1669624370311.png

What is the most suitable way to achieve this?

1 ACCEPTED SOLUTION
mangaus1111
Solution Sage
Solution Sage

Hi @Butterfly ,

try this measure

mangaus1111_0-1669633059645.png

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

View solution in original post

5 REPLIES 5
mangaus1111
Solution Sage
Solution Sage

Hi @Butterfly ,

try this measure

mangaus1111_0-1669633059645.png

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

This also works really well, thanks a lot!

Looks kinda like this in my case: 

Categories = CALCULATE(CONCATENATEX(CategoriesElementsRELATED(Categories[CategoryName]) & IF(CategoriesTraining[Comment]="", "", " (" & CategoriesTraining[Comment] & ")")", "))

mangaus1111
Solution Sage
Solution Sage

Hi @Butterfly ,

you must use the function CONCATENATEX

CONCATENATEX - DAX Guide

 

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

 

Thank you for the hint, however, I still couldn't reach my final goal. 

I created a new column: 

Categories = CALCULATE(CONCATENATEX(CategoriesElements, CategoriesElements[CategoryID]), ", ")

Which results in a table like this: 

Butterfly_0-1669630392695.png

But instead of these numbers (CategoryID) i want to display "CategoryName" from the related Table "Categories". 

How can I tweak this code so that it displays the CategoryName instead of its ID?

After further experimenting I found the complete solution: 

Step 1

Create the Column that lists all related Categories like this: 

Categories = CALCULATE(CONCATENATEX(CategoriesElements, CategoriesElements[CategoryID] ", "))

Result:

Butterfly_0-1669632559172.png

 

Step 2

Display CategoryName instead of its ID: 

Categories = CALCULATE(CONCATENATEX(NATURALINNERJOIN(Categories, CategoriesElements), Categories[CategoryName], ", "))

Result:

Butterfly_1-1669632682094.png

 

 

Step 3

Add comment of relationship Table: 

Categories = CALCULATE(CONCATENATEX(NATURALINNERJOIN(Categories, CategoriesElements), Categories[CategoryName] & IF(CategoriesTraining[Comment]="", "", " (" & CategoriesTraining[Comment] & ")"), ", "))

Result: 

Butterfly_2-1669633237008.png

 

special thanks to @mangaus1111 for the initial hint to CONCATENATEX

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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