閱讀英文

共用方式為


Table.HasColumns

語法

Table.HasColumns(table as table, columns as any) as logical 

關於

表示 table 是否包含指定的資料行 columns。 如果資料表包含資料行,則會傳回 true;否則會傳回 false

範例 1

判斷資料表是否具有 [Name] 資料行。

使用方式

TTable.HasColumns(
    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"
)

輸出

true

範例 2

找出資料表是否具有 [Name] 和 [PhoneNumber] 資料行。

使用方式

Table.HasColumns(
    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", "PhoneNumber"}
)

輸出

false