Table.PositionOf
Table.PositionOf(table as table, row as record, optional occurrence as nullable number, optional equationCriteria as any) as any
返回 row
在指定的 table
中第一次出现的行位置。如果找不到该值,则返回 -1。
table
: 输入表。row
: 表中要查找其位置的行。occurrence
: [可选] 指定要返回的行的出现次数。equationCriteria
: [可选] 控制表行之间的比较。
示例:
查找 [a = 2, b = 4] 在表 ({[a = 2, b = 4], [a = 6, b = 8], [a = 2, b = 4], [a = 1, b = 4]})
中第一次出现的位置。
使用情况:
Table.PositionOf(Table.FromRecords({[a = 2, b = 4], [a = 1, b = 4], [a = 2, b = 4], [a = 1, b = 4]}), [a = 2, b = 4])
输出:
0
示例:
查找 [a = 2, b = 4] 在表 ({[a = 2, b = 4], [a = 6, b = 8], [a = 2, b = 4], [a = 1, b = 4]})
中第二次出现的位置。
使用情况:
Table.PositionOf(Table.FromRecords({[a = 2, b = 4], [a = 1, b = 4], [a = 2, b = 4], [a = 1, b = 4]}), [a = 2, b = 4], 1)
输出:
2
示例:
查找 [a = 2, b = 4] 在表 ({[a = 2, b = 4], [a = 6, b = 8], [a = 2, b = 4], [a = 1, b = 4]})
中所有出现的位置。
使用情况:
Table.PositionOf(Table.FromRecords({[a = 2, b = 4], [a = 1, b = 4], [a = 2, b = 4], [a = 1, b = 4]}), [a = 2, b = 4], Occurrence.All)
输出:
{0, 2}