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
eloomis
Advocate II
Advocate II

Replace all Distinct Values in a column

I have a column "Employee" that consists of many different employees repeated multiple times with the cooresponding projects they work on.

 

ProjectID | Employee
123            John

456            John

789            John

321            Chris

654            Chris

987            Chris

 

I want to replace the names with an anonymous identifier. John will be "Employee 1", Chris will be "Employee 2".

 

I found this solution, but I want to know how to replace the values without having to enter specific values. There are many employees to account for, and in future, a new employee may get added and I don't want to have to alter the code.

https://community.powerbi.com/t5/Power-Query/Replacing-multiple-value-at-once/m-p/1365221#M43024

 

Is there a way to replace a list of values with a corresponding list of values without naming all the values in the code?

1 ACCEPTED SOLUTION
HotChilli
Super User
Super User

You could : use a duplicate of the table, remove all columns except Name, Remove Duplicates,

Add an Index column (from 1). Add a custom column "Employee" & Index number

You can then Merge that Query with the original on the name column to bring the EmployeeX text back

View solution in original post

3 REPLIES 3
Daryna_SHD
Advocate I
Advocate I

It can be also done in the same table:

1) group by Employee, use operation "All rows"

2) add index column

3) expand column with grouped rows

4) delete column with Employees' names

HotChilli
Super User
Super User

You could : use a duplicate of the table, remove all columns except Name, Remove Duplicates,

Add an Index column (from 1). Add a custom column "Employee" & Index number

You can then Merge that Query with the original on the name column to bring the EmployeeX text back

This worked, thank you!

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.

Top Solution Authors
Top Kudoed Authors