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
carrl284
Frequent Visitor

DAX Measure to Concatenate Unique Strings

Hi,

I have a table where people have worked dates on a job.  The start and end columns are split to a row for each day. This results in the comments being duplicated for every day. Can anyone show me how to create a measure that will concatenate the comments for each person but not duplicate them?  I tried concatenatex but got "covering for X, covering for X, covering for X, back problems, back problems, back problems" for EmployeeId1.

EmployeeIdStartEndDaysCategoryComment
101 April 202103 April 202101 April 2021Coveringcovering for X
101 April 202103 April 202102 April 2021Coveringcovering for X
101 April 202103 April 202103 April 2021Coveringcovering for X
201 April 202102 April 202101 April 2021Overtimerate * 1.5
201 April 202102 April 202102 April 2021Overtimerate * 1.5
104 April 202107 April 202104 April 2021Sickback problems
104 April 202107 April 202105 April 2021Sickback problems
104 April 202107 April 202106 April 2021Sickback problems
104 April 202107 April 202107 April 2021Sickback problems
224 April 202126 April 202124 April 2021Holidaypaid holiday
224 April 202126 April 202125 April 2021Holidaypaid holiday
224 April 202126 April 202126 April 2021Holidaypaid holiday


This is how I want to present the data, I have created a measure counting how many days for each category but I cannot work out how to get the comments appearing in one line.

EmployeeIdStartEndCoveringOvertimeSickHolidayComment
101 April 202130 April 20213 4 covering for X, back problems
201 April 202130 April 2021 2 3rate * 1.5 , paid holiday

 

Many Thanks

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi, @carrl284 

Please try the link down below.

 

Picture1.png

 

Comments =
IF (
ISFILTERED ( 'Table'[EmployeeId] ),
CONCATENATEX (
SUMMARIZE (
FILTER ( ALL ( 'Table' ), 'Table'[EmployeeId] = MAX ( 'Table'[EmployeeId] ) ),
'Table'[Comment]
),
'Table'[Comment],
", "
)
)
 
 

Hi, My name is Jihwan Kim.


If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.


Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


View solution in original post

5 REPLIES 5
Anonymous
Not applicable

@carrl284 can you try pivoting your date columns and your employeeid should be the column name and you should return your comments while pivoting, that way we get the comments on the corresponding days in a row for an employee, you will eliminate the duplicates which you have shown in your image. Then you can try your concatenate DAX, you might get blanks using this method that you can take care of I believe.

 

Concatenate and Date.PNG

 

Please mark this as solution, if I helped you well.

 

Thanks

Hi @Anonymous Thanks for the quick response.  In my actual model there is a lot more going on so I don't think I could face reshaping the data model now.  

Jihwan_Kim
Super User
Super User

Hi, @carrl284 

Please try the link down below.

 

Picture1.png

 

Comments =
IF (
ISFILTERED ( 'Table'[EmployeeId] ),
CONCATENATEX (
SUMMARIZE (
FILTER ( ALL ( 'Table' ), 'Table'[EmployeeId] = MAX ( 'Table'[EmployeeId] ) ),
'Table'[Comment]
),
'Table'[Comment],
", "
)
)
 
 

Hi, My name is Jihwan Kim.


If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.


Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


Hi @Jihwan_Kim This is exactly what I needed.  Thank you so much for your quick response.

Anonymous
Not applicable

Having a doubt, what if instead of 2 rows for employee id 1, I want 1 row which includes dates starting from 1/4/21 - 30/4/21. How should my DAX be modified? Just Curious!

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.