閱讀英文

共用方式為


Table.Contains

語法

Table.Contains(table as table, row as record, optional equationCriteria as any) as logical

關於

指出指定的記錄 row 是否顯示成 table 中資料列。 可指定選擇性參數 equationCriteria 以控制資料表資料列之間的比較方式。

範例 1

判斷資料表是否包含資料列。

使用方式

Table.Contains(
    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"]
    }),
    [Name = "Bob"]
)

輸出

true

範例 2

判斷資料表是否包含資料列。

使用方式

Table.Contains(
    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"]
    }),
    [Name = "Ted"]
)

輸出

false

範例 3

在只比較 [Name] 資料行的情況下,判斷資料表是否包含資料列。

使用方式

Table.Contains(
    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"]
    }),
    [CustomerID = 4, Name = "Bob"],
    "Name"
)

輸出

true

方程式準則