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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
DieterH
New Member

RemoveMatchingRows

Hello,

I tried to remove matching rows. I used the example out of documentation

Table.RemoveMatchingRows(Table.FromRecords(

{ [OrderID = 1, CustomerID = 1, Item = "Fishing rod", Price = 100.0],

[OrderID = 2, CustomerID = 1, Item = "1 lb. worms", Price = 5.0],

[OrderID = 3, CustomerID = 2, Item = "Fishing net", Price = 25.0],

[OrderID = 4, CustomerID = 3, Item = "Fish tazer", Price = 200.0],

[OrderID = 5, CustomerID = 3, Item = "Bandaids", Price = 2.0],

[OrderID = 6, CustomerID = 1, Item = "Tackle box", Price = 20.0],

[OrderID = 7, CustomerID = 5, Item = "Bait", Price = 3.25],

[OrderID = 8, CustomerID = 5, Item = "Fishing Rod", Price = 100.0],

[OrderID = 9, CustomerID = 6, Item = "Bait", Price = 3.25] } ),

{[CustomerID = 3]}, "CustomerID")

I have 2 questions.

1. This code only works with the condition =. If I use [CustomerID <= 3] it brings up an error message. How can I make a condition like <= 3?

2. If I have a Date-Field instead of numeric like in the example above. It is not possible to use Date-functions, like [Date.Year(MyDate) = 2016]. Isn`t it possible to use Functions inside RemoveMatchedRows?

Thanks for your help

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @DieterH,

 

For your requirement, you can refer to below formula:

 

>>1. This code only works with the condition =. If I use [CustomerID <= 3] it brings up an error message. How can I make a condition like <= 3?

 

let
    Source = Table.RemoveMatchingRows(Table.FromRecords(

{ [OrderID = 1, CustomerID = 1, Item = "Fishing rod", Price = 100.0],

[OrderID = 2, CustomerID = 1, Item = "1 lb. worms", Price = 5.0],

[OrderID = 3, CustomerID = 2, Item = "Fishing net", Price = 25.0],

[OrderID = 4, CustomerID = 3, Item = "Fish tazer", Price = 200.0],

[OrderID = 5, CustomerID = 3, Item = "Bandaids", Price = 2.0],

[OrderID = 6, CustomerID = 1, Item = "Tackle box", Price = 20.0],

[OrderID = 7, CustomerID = 5, Item = "Bait", Price = 3.25],

[OrderID = 8, CustomerID = 5, Item = "Fishing Rod", Price = 100.0],

[OrderID = 9, CustomerID = 6, Item = "Bait", Price = 3.25] } ),

{[CustomerID = 3]}, each [CustomerID] <=3)

in
    Source

 

>>2. If I have a Date-Field instead of numeric like in the example above. It is not possible to use Date-functions, like [Date.Year(MyDate) = 2016]. Isn`t it possible to use Functions inside RemoveMatchedRows?

 

Yes, it is possible. If you want to keep use the remove mathch row funciton, you can modify the condition query to Date.Year([Date ColumnName]) <> 2016.

 

In addition, you can also use Table.SelectRows to achieve your requirement.

 

Table.SelectRows(Table.FromRecords(

{ [OrderID = 1, CustomerID = 1, Item = "Fishing rod", Price = 100.0],

[OrderID = 2, CustomerID = 1, Item = "1 lb. worms", Price = 5.0],

[OrderID = 3, CustomerID = 2, Item = "Fishing net", Price = 25.0],

[OrderID = 4, CustomerID = 3, Item = "Fish tazer", Price = 200.0],

[OrderID = 5, CustomerID = 3, Item = "Bandaids", Price = 2.0],

[OrderID = 6, CustomerID = 1, Item = "Tackle box", Price = 20.0],

[OrderID = 7, CustomerID = 5, Item = "Bait", Price = 3.25],

[OrderID = 8, CustomerID = 5, Item = "Fishing Rod", Price = 100.0],

[OrderID = 9, CustomerID = 6, Item = "Bait", Price = 3.25] } ),

{[CustomerID = 3]}, each [CustomerID] >3 and DateYear([Date]) = 2016 )

 

 

Regards,

Xiaoxin Sheng

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @DieterH,

 

For your requirement, you can refer to below formula:

 

>>1. This code only works with the condition =. If I use [CustomerID <= 3] it brings up an error message. How can I make a condition like <= 3?

 

let
    Source = Table.RemoveMatchingRows(Table.FromRecords(

{ [OrderID = 1, CustomerID = 1, Item = "Fishing rod", Price = 100.0],

[OrderID = 2, CustomerID = 1, Item = "1 lb. worms", Price = 5.0],

[OrderID = 3, CustomerID = 2, Item = "Fishing net", Price = 25.0],

[OrderID = 4, CustomerID = 3, Item = "Fish tazer", Price = 200.0],

[OrderID = 5, CustomerID = 3, Item = "Bandaids", Price = 2.0],

[OrderID = 6, CustomerID = 1, Item = "Tackle box", Price = 20.0],

[OrderID = 7, CustomerID = 5, Item = "Bait", Price = 3.25],

[OrderID = 8, CustomerID = 5, Item = "Fishing Rod", Price = 100.0],

[OrderID = 9, CustomerID = 6, Item = "Bait", Price = 3.25] } ),

{[CustomerID = 3]}, each [CustomerID] <=3)

in
    Source

 

>>2. If I have a Date-Field instead of numeric like in the example above. It is not possible to use Date-functions, like [Date.Year(MyDate) = 2016]. Isn`t it possible to use Functions inside RemoveMatchedRows?

 

Yes, it is possible. If you want to keep use the remove mathch row funciton, you can modify the condition query to Date.Year([Date ColumnName]) <> 2016.

 

In addition, you can also use Table.SelectRows to achieve your requirement.

 

Table.SelectRows(Table.FromRecords(

{ [OrderID = 1, CustomerID = 1, Item = "Fishing rod", Price = 100.0],

[OrderID = 2, CustomerID = 1, Item = "1 lb. worms", Price = 5.0],

[OrderID = 3, CustomerID = 2, Item = "Fishing net", Price = 25.0],

[OrderID = 4, CustomerID = 3, Item = "Fish tazer", Price = 200.0],

[OrderID = 5, CustomerID = 3, Item = "Bandaids", Price = 2.0],

[OrderID = 6, CustomerID = 1, Item = "Tackle box", Price = 20.0],

[OrderID = 7, CustomerID = 5, Item = "Bait", Price = 3.25],

[OrderID = 8, CustomerID = 5, Item = "Fishing Rod", Price = 100.0],

[OrderID = 9, CustomerID = 6, Item = "Bait", Price = 3.25] } ),

{[CustomerID = 3]}, each [CustomerID] >3 and DateYear([Date]) = 2016 )

 

 

Regards,

Xiaoxin Sheng

Thanks so much for your help, Xiaoxin, but there is something I don't understand about the syntax and semantics of this. The last two arguments to Table.RemoveMatchingRows are

{[CustomerID = 3]}, each [CustomerID] <=3

which seems to say to remove all rows where the CustomerID column is equal to 3, but then the matching criterion says CustomerID smaller than or equal to 3? How should I interpret this? They seem to specify two different sets of rows. I have read the documentation for Table.RemoveMatchingRows, but that didn't make me any wiser. Thanks for any pointers!

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.