Table.PositionOf
语法
Table.PositionOf(table as table, row as record, optional occurrence as any, optional equationCriteria as any) as any
关于
返回 row
在指定 table
中第一个实例的位置。 如果未找到匹配项,则返回 -1。
table
:输入表。row
:表中要查找其位置的行。occurrence
:[可选] 指定要返回的行的匹配项。equationCriteria
:[可选] 控制表行之间的比较。
示例 1
查找 [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
示例 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], 1)
输出
2
示例 3
查找 [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 }