Table.SelectRows
語法
Table.SelectRows(table as table, condition as function) as table
關於
從 table
傳回符合所選取 condition
資料列的資料表。
範例 1
在資料表中選取 [CustomerID] 資料行中值大於 2 的資料列。
使用方式
Table.SelectRows(
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"]
})
範例 2
在資料表中選取名稱沒有包含 "B" 的資料列。
使用方式
Table.SelectRows(
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 not Text.Contains([Name], "B")
)
輸出
Table.FromRecords({
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"],
[CustomerID = 4, Name = "Ringo", Phone = "232-1550"]
})