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
Anonymous
Not applicable

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 @Anonymous ,

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 @Anonymous ,

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.

Anonymous
Not applicable

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 @Anonymous ,

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.

 

Anonymous
Not applicable

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?

Anonymous
Not applicable

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
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!

December 2024

A Year in Review - December 2024

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