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
Anonymous
Not applicable

Remove all rows with same ID based on another row's input

Hi, I have a table like the one below but with more columns. If I wanted to remove someone who has Status = Complete, but remove all of their data how would I do so?

I have tried this but it is only removing that specific row, but I need it to remove all the rows including that ID.

 

Thanks in advance.

 

 

 

IDStatus
101Started
101Progress
101Complete
204Started
204Progress
305Started
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

 

Here's my solution.

1.Group by ID.

vstephenmsft_0-1649751091220.png

vstephenmsft_1-1649751156714.png

vstephenmsft_2-1649751162036.png

 

2.Add a custom column to check if Status = "Complete".

vstephenmsft_3-1649751188507.png

vstephenmsft_4-1649751236358.png

 

 

3.Remove the rows with ture.

vstephenmsft_5-1649751276436.png

vstephenmsft_6-1649751283307.png

 

 

4.Expand the Count column and remove the unneeded column.

vstephenmsft_7-1649751304915.png

vstephenmsft_8-1649751330992.png

vstephenmsft_9-1649751337154.png

 

You can check more details from my attachment.

 

 

 

Best Regards,

Stephen Tao

 

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

7 REPLIES 7
Anonymous
Not applicable

Hi @Anonymous ,

 

Here's my solution.

1.Group by ID.

vstephenmsft_0-1649751091220.png

vstephenmsft_1-1649751156714.png

vstephenmsft_2-1649751162036.png

 

2.Add a custom column to check if Status = "Complete".

vstephenmsft_3-1649751188507.png

vstephenmsft_4-1649751236358.png

 

 

3.Remove the rows with ture.

vstephenmsft_5-1649751276436.png

vstephenmsft_6-1649751283307.png

 

 

4.Expand the Count column and remove the unneeded column.

vstephenmsft_7-1649751304915.png

vstephenmsft_8-1649751330992.png

vstephenmsft_9-1649751337154.png

 

You can check more details from my attachment.

 

 

 

Best Regards,

Stephen Tao

 

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

What if you have more thank just 1 criteria of Status = Completed? How would you add Status = Completed and Rank = 0 as an example?

Anonymous
Not applicable

Thank you but as I have more columns it is not working. How would I add in what you did to this as when I tried replacing it, it did not work. This is my current advanced editor:

 

 

let

    Source = Sql.Database("company"),

    dbo_People = Source{[Schema="dbo",Item="People"]}[Data],

    #"Removed Other Columns" = Table.SelectColumns(dbo_People,{"Items", "Text", "Roles", "State"}),

    #"Expanded Items" = Table.ExpandRecordColumn(#"Removed Other Columns", "Items", {"Id", "First", "Second"}, {"Items.Id", "Items.First", "Items.Second"}),

    #"Expanded Text" = Table.ExpandTableColumn(#"Expanded Items", "Text", {"Section", "Text", "Deleted"}, {"Text.Section", "Text.Text", "Text.Deleted"}),

    #"Filtered Rows" = Table.SelectRows(#"Expanded Text", each ([Text.Section] = 120) and ([Text.Deleted] = false)),

    #"Expanded Roles" = Table.ExpandRecordColumn(#"Filtered Rows", "Roles", {"End", "Projects", "Start", "Title"}, {"Roles.End", "Roles.Projects", "Roles.Start", "Roles.Title"}),

    #"Expanded Roles.Projects" = Table.ExpandRecordColumn(#"Expanded Roles", "Roles.Projects", {"Name"}, {"Roles.Projects.Name"})

in

    #"Expanded Roles.Projects"

Table which you had posted in the problem is generated at which step? Can you post a screenshot of your final table from where you want my code to be working? 

Vijay_A_Verma
Super User
Super User

Since performance is not a major consideration here, you can perform Left Anti join after filtering on Complete. Replace Source appropriately here. 

 

let
    Source = Excel.CurrentWorkbook(){[Name="Table5"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", Int64.Type}, {"Status", type text}}),
    #"Filtered Rows" = Table.SelectRows(#"Changed Type", each ([Status] = "Complete")),
    #"Merged Queries" = Table.NestedJoin(#"Changed Type", {"ID"}, #"Filtered Rows", {"ID"}, "Filtered Rows", JoinKind.LeftAnti),
    #"Removed Columns" = Table.RemoveColumns(#"Merged Queries",{"Filtered Rows"})
in
    #"Removed Columns"

 

Anonymous
Not applicable

Where would I paste this?

Import your data into Power Query.

Home tab - Advanced Editor

Copy the line beginning with Source from there into notepad.

Now remove everything from Advanced Editor.

Paste my code there.

Delete the source line from my code.

Paste the source line from notepad there as second statement i.e. after let i.e. in place where my original source line was there. Ensure that comma is at the end. 

Press OK

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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