Table.FirstN
返回指定的前几个计数行。
Syntax
Table.FirstN(
table as table,
countOrCondition as any
) as table
Remarks
返回表 table 的前几行,具体取决于 countOrCondition 的值:
- 如果
countOrCondition为数字,则将返回多行(从顶部开始)。 - 如果
countOrCondition是条件,将返回满足此条件的行,直到行不满足条件为止。
Examples
Example #1
查找表的前两行。
Table.FirstN(
Table.FromRecords({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"]
}),
2
)
Result:
Table.FromRecords({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"]
})
Example #2
查找表中 [a] > 0 的前几行。
Table.FirstN(
Table.FromRecords({
[a = 1, b = 2],
[a = 3, b = 4],
[a = -5, b = -6]
}),
each [a] > 0
)
Result:
Table.FromRecords({
[a = 1, b = 2],
[a = 3, b = 4]
})
Category
Table.Row operations