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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Mikee5
Regular Visitor

Remove group of rows based on column data

How do I write a query to remove all of the rows of a "group" based on some column data.  For example in the below I want to remove all Owner rows where the driver doesn't own a Toyota.

Owner   Car
JonesHonda
JonesToyota
JonesHonda
SmithVW
SmithFord
TaylorHyundai
TaylorToyota
TaylorToyota

 

The result I am after would remove all Smith rows because they have never owned a Toyota

Owner  Car
JonesHonda
JonesToyota
JonesHonda
TaylorHyundai
TaylorToyota
TaylorToyota

 

Just learning so any help appreciated.

1 REPLY 1
AlienSx
Super User
Super User

Hello, @Mikee5 Group by owner, check if [Car] column contains "Toyota" and then select TRUE only. Just an idea.

 

let
    Source = your_table,
    group = Table.Group(Source, "Owner", {{"rows", each _}, {"Toyota_owner", each List.Contains(_[Car], "Toyota")}}),
    filter = Table.SelectRows(group, each ([Toyota_owner] = true)),
    result = Table.Combine(filter[rows])
in
    result

 

another option is to filter table to get a list of Toyota owners only and then filter table again by Owners column

let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    names = List.Buffer(List.Distinct(Table.SelectRows(Source, each [Car] = "Toyota")[Owner])),
    result = Table.SelectRows(Source, each List.Contains(names, [Owner]))
in
    result

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.