Table.PositionOf
Table.PositionOf(table as table, row as record, optional occurrence as any, optional equationCriteria as any) as any
傳回所指定 table
中第一次出現 row
的資料列位置。 如果找不到出現項目,則會傳回 -1。
table
:輸入資料表。row
:要在資料表中尋找其位置的資料列。occurrence
:[選擇性] 指定要傳回哪些資料列的出現項目。equationCriteria
[選擇性] 控制資料表資料列之間的比較方式。
尋找資料表 ({[a = 2, b = 4], [a = 6, b = 8], [a = 2, b = 4], [a = 1, b = 4]})
中第一次出現 [a = 2, 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 = 6, b = 8], [a = 2, b = 4], [a = 1, b = 4]})
中第二次出現 [a = 2, 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 = 6, b = 8], [a = 2, b = 4], [a = 1, b = 4]})
中所有出現 [a = 2, 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}