Table.RemoveFirstN
语法
Table.RemoveFirstN(table as table, optional countOrCondition as any) as table
关于
返回一个表,该表不包含表 table
中前数行 countOrCondition
(行数为指定数字)。 删除的行数取决于可选参数 countOrCondition
。
- 如果省略
countOrCondition
则只删除第一行。 - 如果
countOrCondition
是数字,则将删除多个行(从顶部开始)。 - 如果
countOrCondition
是条件,则将删除满足条件的行,直到出现不满足条件的行为止。
示例 1
删除表的第一行。
使用情况
Table.RemoveFirstN(
Table.FromRecords({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"],
[CustomerID = 4, Name = "Ringo", Phone = "232-1550"]
}),
1
)
输出
Table.FromRecords({
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"],
[CustomerID = 4, Name = "Ringo", Phone = "232-1550"]
})
示例 2
删除表的前两行。
使用情况
Table.RemoveFirstN(
Table.FromRecords({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"],
[CustomerID = 4, Name = "Ringo", Phone = "232-1550"]
}),
2
)
输出
Table.FromRecords({
[CustomerID = 3, Name = "Paul", Phone = "543-7890"],
[CustomerID = 4, Name = "Ringo", Phone = "232-1550"]
})
示例 3
删除表中 [CustomerID] <=2 的前几行。
使用情况
Table.RemoveFirstN(
Table.FromRecords({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"] ,
[CustomerID = 3, Name = "Paul", Phone = "543-7890"] ,
[CustomerID = 4, Name = "Ringo", Phone = "232-1550"]
}),
each [CustomerID] <= 2
)
输出
Table.FromRecords({
[CustomerID = 3, Name = "Paul", Phone = "543-7890"],
[CustomerID = 4, Name = "Ringo", Phone = "232-1550"]
})