Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
jcymclean1
Frequent Visitor

Keeping Specific Duplicates in Table

New to Power Bi Community! Hope i have done this correctly.

 

I built a dynamic org chart in Power Bi (using Akvelon Visual). It worked wonderfully - but now i have been asked to be able to compare with FUTURE NEEDS.

 

The following is a table which has the EMPLOYEES and who they report to:

 

jcymclean1_0-1637896321654.png

 

Basically, i want to remove the duplicate STAFF NAME - but keep the REASSIGNED person. 

 

There are no dates, as i have seen solutions using time... 

 

Thank you!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @jcymclean1 ,

 

Please follow these steps:

1.Click Staff Name column --> Group By -->All Rows:

Eyelyn9_0-1638325633854.png

2.Add a custom column:

=if Table.RowCount([Count])> 1 then Table.SelectRows([Count],each [Status]="Reassign") else [Count]

Eyelyn9_1-1638325737511.png

3.Remove Count column and expand Custom column, the output is shown below:

Eyelyn9_2-1638325841780.png

 

The whole M syntax:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjFQ0lHyys/IUwjOzSzJAHJQUKwOUIkZkOURpOCSWZSaXJJfhI0XkpqYC2QZArGzqz+Q9Esth2g2B3JcMtMzSxJzFHwT8xLTU4uwigTn55SWZObnKbiklqXm5BfkpuaV4DEWh7NxWBeUmlhcnJmeB9FrAVJooODi6x+M0IhhINiqWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [EmployeeKey = _t, #"Staff Name" = _t, Title = _t, Department = _t, ParentEmployeeKey = _t, #"Report to" = _t, Status = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"EmployeeKey", Int64.Type}, {"Staff Name", type text}, {"Title", type text}, {"Department", type text}, {"ParentEmployeeKey", Int64.Type}, {"Report to", type text}, {"Status", type text}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Staff Name"}, {{"Count", each _, type table [EmployeeKey=nullable number, Staff Name=nullable text, Title=nullable text, Department=nullable text, ParentEmployeeKey=nullable number, Report to=nullable text, Status=nullable text]}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each if Table.RowCount([Count])> 1 then Table.SelectRows([Count],each [Status]="Reassign") else [Count]),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Count"}),
    #"Expanded Custom" = Table.ExpandTableColumn(#"Removed Columns", "Custom", {"EmployeeKey", "Title", "Department", "ParentEmployeeKey", "Report to", "Status"}, {"EmployeeKey", "Title", "Department", "ParentEmployeeKey", "Report to", "Status"})
in
    #"Expanded Custom"

 

 

Best Regards,
Eyelyn Qin
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

3 REPLIES 3
Anonymous
Not applicable

Hi @jcymclean1 ,

 

Please follow these steps:

1.Click Staff Name column --> Group By -->All Rows:

Eyelyn9_0-1638325633854.png

2.Add a custom column:

=if Table.RowCount([Count])> 1 then Table.SelectRows([Count],each [Status]="Reassign") else [Count]

Eyelyn9_1-1638325737511.png

3.Remove Count column and expand Custom column, the output is shown below:

Eyelyn9_2-1638325841780.png

 

The whole M syntax:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjFQ0lHyys/IUwjOzSzJAHJQUKwOUIkZkOURpOCSWZSaXJJfhI0XkpqYC2QZArGzqz+Q9Esth2g2B3JcMtMzSxJzFHwT8xLTU4uwigTn55SWZObnKbiklqXm5BfkpuaV4DEWh7NxWBeUmlhcnJmeB9FrAVJooODi6x+M0IhhINiqWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [EmployeeKey = _t, #"Staff Name" = _t, Title = _t, Department = _t, ParentEmployeeKey = _t, #"Report to" = _t, Status = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"EmployeeKey", Int64.Type}, {"Staff Name", type text}, {"Title", type text}, {"Department", type text}, {"ParentEmployeeKey", Int64.Type}, {"Report to", type text}, {"Status", type text}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Staff Name"}, {{"Count", each _, type table [EmployeeKey=nullable number, Staff Name=nullable text, Title=nullable text, Department=nullable text, ParentEmployeeKey=nullable number, Report to=nullable text, Status=nullable text]}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each if Table.RowCount([Count])> 1 then Table.SelectRows([Count],each [Status]="Reassign") else [Count]),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Count"}),
    #"Expanded Custom" = Table.ExpandTableColumn(#"Removed Columns", "Custom", {"EmployeeKey", "Title", "Department", "ParentEmployeeKey", "Report to", "Status"}, {"EmployeeKey", "Title", "Department", "ParentEmployeeKey", "Report to", "Status"})
in
    #"Expanded Custom"

 

 

Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Thank you so much! 

 

Appreciate your efforts - can get frustrating when new and you hit a road block!

 

lbendlin
Super User
Super User

Group the table by maximum status and then ungroup again.

 

Please provide sanitized sample data that fully covers your issue. Paste the data into a table in your post or use one of the file services. 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors