Table.RemoveMatchingRows
从表中删除出现的所有指定行。
Syntax
Table.RemoveMatchingRows(
table as table,
rows as list,
optional equationCriteria as any
) as table
Remarks
从表格中删除出现的所有指定行。
table: 要搜索的表格。rows: 一个列表,其中包含有关要移除的行的信息。equationCriteria: (可选)指定比较值时如何确定相等性。此参数可以是键选择器函数、比较器函数,或表格中比较各行时所用的列的列表。
Examples
Example #1
从指定表格中移除所有符合以下条件的行: [a = 1]。
Table.RemoveMatchingRows(
Table.FromRecords({
[a = 1, b = 2],
[a = 3, b = 4],
[a = 1, b = 6]
}),
{[a = 1]},
"a"
)
Result:
Table.FromRecords({[a = 3, b = 4]})
Example #2
移除已取消的订单,忽略大小写。
let
CurrentOrders = #table(type table[OrderID = number, Product = text, Quantity = number],
{
{101, "Widget", 5},
{102, "Gadget", 3},
{103, "Widget", 5}
}),
CanceledOrders = {
[OrderID = 103, Product = "widget", Quantity = 5]
},
FilteredOrders = Table.RemoveMatchingRows(CurrentOrders, CanceledOrders, Comparer.OrdinalIgnoreCase)
in
FilteredOrders
Result:
#table(type table[OrderID = number, Product = text, Quantity = number],
{
{101, "Widget", 5},
{102, "Gadget", 3}
})
Example #3
移除所有发生在美国假期的维护 任务。
let
MaintenanceSchedule = #table(type table [Task = text, Date = date],
{
{"HVAC Check", #date(2025, 7, 10)}, // Not a holiday
{"Window Washing", #date(2025, 9, 1)}, // Labor Day
{"Fire Drill", #date(2025, 9, 17)}, // Not a holiday
{"Light Bulb Replacement", #date(2025, 11, 27)} // Thanksgiving
}),
USHolidays = {
[Date = #date(2025, 1, 1)], // New Year's Day
[Date = #date(2025, 7, 4)], // Independence Day
[Date = #date(2025, 9, 1)], // Labor Day
[Date = #date(2025, 11, 27)], // Thanksgiving
[Date = #date(2025, 12, 25)] // Christmas
},
FilteredSchedule = Table.RemoveMatchingRows(
MaintenanceSchedule,
USHolidays,
{"Date"}
)
in
FilteredSchedule
Result:
#table(type table[Task = text, Date = date],
{
{"HVAC Check", #date(2025, 7, 10)},
{"Fire Drill", #date(2025, 9, 17)}
})
Category
Table.Membership