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
spider_Monkey
Helper I
Helper I

Need to Remove Duplicated Text String in Calculated Columns

Hello, 

I need to remove duplicate project names and I used the dax below (ignore red needed to remove identifying data). If you remove the Values It currently shows up as:

Project: A, A, A, B, B,B,C,C,D,D,D

spider_Monkey_0-1705975259175.png

 

 

What I want is:

Project: A,B,C,D

 

I thought I could get that with Values (See Below) at the end but it gives me "A table of multiple values was supplied where a single value was expected."

 

spider_Monkey_1-1705975292497.png

 

 

I thought this would get me close @https://community.fabric.microsoft.com/t5/Desktop/To-remove-duplicate-char-from-string-on-each-row-using-DAX/m-p/2896296

6 REPLIES 6
v-weiyan1-msft
Community Support
Community Support

Hi @spider_Monkey ,

 

Can you share sample data and sample output in table format? We can better understand the problem and assist you. Show it as a screenshot or excel. Please remove any sensitive data in advance.

 

Best Regards,
Yulia Yan

spider_Monkey
Helper I
Helper I

thanks for the reply @123abc, the problem is I need to use the filters to make sure it's within the date range as well as the ID's need to match. 

 

I forgot to mention I need to make this column on the timesheet table

 

I am looking up the project names off a different table so not quite sure how to do that with this one! 

123abc
Community Champion
Community Champion

Assuming you have a table named "Projects" with a column named "Project," you can create a calculated column to store the unique values. Here's an example DAX formula:

 

UniqueProjects = CONCATENATEX(VALUES(Projects[Project]), Projects[Project], ", ")

 

This formula uses the VALUES function to get a unique list of project names and then uses CONCATENATEX to concatenate these values into a single comma-separated string.

Make sure to replace "Projects" and "Project" with your actual table and column names.

If you encounter the error "A table of multiple values was supplied where a single value was expected," it may be due to the context in which you are using the formula. Ensure that you are using it in the appropriate context, such as in a calculated column or a measure.

If you still face issues, please provide more details about your data model and the specific context in which you are using the formula so that I can provide more targeted assistance.

 

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

 

In case there is still a problem, please feel free and explain your issue in detail, It will be my pleasure to assist you in any way I can.

So the problem is I need to use filters to determine if it was done by a specific user during a specific time. So where would I put the filters into the formula? 

If you need to filter the project names based on specific criteria such as the user who performed the task and the time frame during which the task was performed, you can incorporate these filters into the DAX expression. Assuming you have a column named UserID in your Timesheet table and you want to filter based on a specific user ID and a time range, you can modify the DAX expression as follows:

 

UniqueProjects =
VAR CurrentUserID = Timesheet[UserID]
VAR StartDate = Timesheet[StartDate]
VAR EndDate = Timesheet[EndDate]
RETURN
CONCATENATEX(
FILTER(
VALUES(ProjectsTable[ProjectName]),
ProjectsTable[UserID] = CurrentUserID &&
ProjectsTable[Date] >= StartDate &&
ProjectsTable[Date] <= EndDate
),
ProjectsTable[ProjectName],
", ",
ProjectsTable[ProjectName],
ASC
)

 

In this modified expression:

  • CurrentUserID is set to the user ID for the current row in the Timesheet table.
  • StartDate and EndDate are set to the start and end dates for the current row in the Timesheet table.
  • The FILTER function filters the rows from the ProjectsTable based on the following conditions:
    • The user ID matches the CurrentUserID.
    • The date falls within the specified range between StartDate and EndDate.
  • CONCATENATEX concatenates the filtered project names into a comma-separated list.

Make sure to replace UserID, StartDate, EndDate, and ProjectsTable with the actual column names and table name from your data model.

This expression should create a calculated column in the Timesheet table that displays unique project names based on the specified user ID and time frame filters. Adjust the column names and conditions according to your actual data model and requirements.

 
 
 
 

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

 

In case there is still a problem, please feel free and explain your issue in detail, It will be my pleasure to assist you in any way I can.

@123abc  So I can't get it to work, and I get an error when I leave VALUES(ProjectsTable[ProjectName]) in there. If i just use VALUES(ProjectsTable) I get a list but unforunetly it doesn't give me a single list of projects it's still giving me AAAA,BB,CCC. 

 

I want it just to return A, B,C regardless of how many times they work on the project. 

 

UniqueProjects =
VAR CurrentUserID = Timesheet[UserID]
VAR StartDate = Timesheet[StartDate]
VAR EndDate = Timesheet[EndDate]
RETURN
CONCATENATEX(
FILTER(
VALUES(ProjectsTable[ProjectName]),
ProjectsTable[UserID] = CurrentUserID &&
ProjectsTable[Date] >= StartDate &&
ProjectsTable[Date] <= EndDate
),
ProjectsTable[ProjectName],
", ",
ProjectsTable[ProjectName],
ASC
)

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.