Query: How to filter few conditions, delete the ones meeting criteria, and show back the others

Joined
Apr 15, 2020
Messages
2
Office Version
  1. 2016
Platform
  1. Windows
Hello. Say I have columns A, B, C, with the conditions I want to delete is (AND conditions, not OR):
- A = "Zebra"
- B = "Male"
- C = "Small"
I want to remove all the data that matches this requirement (means if there's a zebra, but it's a female, then I don't want to delete that data). Normally how I would do it in excel is filter each columns with the respective conditions, then delete all that are shown, and unfilter back to get the rest of the data. But since Power Query is step-by-step, I can't unfilter back after I delete the data. Does anyone know how can I do this in query?
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
But you can do an anti left join on the table itself by making a duplicate (before filtering).
Say you have the first Query names fAnimals and the Copy Query* (including the filters) is named FilteredSet
Then the merge is something like Table.NestedJoin(fAnimals, {"PrimaryKey"}, FilteredSet, {"PrimaryKey"}, "FilteredSet", JoinKind.LeftAnti)


Or add a custom column like:
Code:
if [A]="Zebra" and [B] = "Male" and [C]="Small" then "Out Of Scope" else "Scope"
Filter on "Scope".

* Better is to make query 1 (up to before filtering) then reference this one in a new query in which you set the filters.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,793
Messages
6,174,635
Members
452,575
Latest member
Fstick546

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top