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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Remove table rows by condition using M Query

I have a very big table with around 650K lines. I want to deselect rows based on values from two columns.

I would like to deselect rows where [Trans Type] = IT and Quantity < 0, meaning i do no want rows having IT as Trans Type and negative Quantity in my dataset.

Below is the screen shot of the table.

 

 

Power BI Deselect Rows Query.JPG

1 ACCEPTED SOLUTION
Jimmy801
Community Champion
Community Champion

Hello @Anonymous 

 

just apply a SelectRows with two conditions.

Here an the code that should work for you:

NewStep = Table.SelectRows(PreviousStep, each [Trans Type]<>"IT" or [Quantity]>=0)

this excludes every row with either IT in Trans Type or Quantity <0

 

If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

Have fun

Jimmy

View solution in original post

4 REPLIES 4
Jimmy801
Community Champion
Community Champion

Hello @Anonymous 

 

just apply a SelectRows with two conditions.

Here an the code that should work for you:

NewStep = Table.SelectRows(PreviousStep, each [Trans Type]<>"IT" or [Quantity]>=0)

this excludes every row with either IT in Trans Type or Quantity <0

 

If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

Have fun

Jimmy

Anonymous
Not applicable

Hi Jimmy,

 

Thank you very much. It worked.

The statement is excluding rows with IT in Trans Type and Quantity <0, which is what i wanted.

Hello @Anonymous 

 

I'm glad it worked out

your feedback is very appreciated

 

have a nice day

 

Jimmy

Just to query this; your original post said you want to filter under BOTH conditions. An OR in there will filter where either applies, so you will be filtering out rows where IT has a Quantity > 0 and every row where Quantity = 0. If that's what you want then fine, but it's not what you asked for. If I am correct you need to use AND instead.

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors
Top Kudoed Authors