cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
EvanFlower
New Member

Trying to return comma separated values from filtered related records in a column

I am trying to find the right formula in DAX for this and getting nowhere.

 

I have two tables:

 

  1. The first table is Projects, this has a ProjectID column, and many others.
  2. The second table is Contacts related to projects, which also has a ProjectID column, which is used to relate contacts to projects many to one. There is also a Role column and a Name column on the Contact table.

 

I need to create a column on the Projects table which shows, in a comma separated list, the Names of all the contacts where 1) ProjectID on the Contact = ProjectID on the Project, and 2) the Role value for that row of the Contact table contains a certain string.

 

I have used CALCULATE successfully to do the same kind of thing, summing values on a related table with multiple filter criteria applied to which rows are included, but I'm failing on getting text values concatenated into a comma separated string in the same way.

 

I need something that works exactly like:

 

CALCULATE(SUM(column),
FILTER(criteria),
FILTER(criteria),
FILTER(criteria)
)

 

Except instead of SUM, it returns a text string with all the names that match the criteria. I've been playing with VALUES and CONCATENATEX, but I can't get the syntax to work.

1 ACCEPTED SOLUTION
amitchandak
Super User IV
Super User IV

@EvanFlower , Create a new column in project table

concatenatex(filter(Contract, contract[project id] = project[project id]),[contract id])

 

refer: https://docs.microsoft.com/en-us/dax/concatenatex-function-dax

https://www.youtube.com/watch?v=du2HSEzng2E

 

correct column name as per need



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

View solution in original post

2 REPLIES 2
EvanFlower
New Member

@amitchandak That did it for a single filter criteria--thank you!

 

What's the best way to do it with multiple fitlers? I just nested a second FILTER within the first, and that seems to work. Is there a more elegant and easier to read method?

amitchandak
Super User IV
Super User IV

@EvanFlower , Create a new column in project table

concatenatex(filter(Contract, contract[project id] = project[project id]),[contract id])

 

refer: https://docs.microsoft.com/en-us/dax/concatenatex-function-dax

https://www.youtube.com/watch?v=du2HSEzng2E

 

correct column name as per need



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

View solution in original post

Helpful resources

Announcements
PBI User Groups

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group!

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are You Ready?

Test your skills now with the Cloud Skills Challenge.

Top Solution Authors