共用方式為


Table.ReplaceKeys

語法

Table.ReplaceKeys(table as table, keys as list) as table

關於

取代指定資料表的索引鍵。

範例 1

取代資料表的現有索引鍵。

使用方式

let
    table = Table.FromRecords({
        [Id = 1, Name = "Hello There"],
        [Id = 2, Name = "Good Bye"]
    }),
    tableWithKeys = Table.AddKey(table, {"Id"}, true),
    resultTable = Table.ReplaceKeys(tableWithKeys, {[Columns = {"Id"}, Primary = false]})
in
    resultTable

輸出

Table.FromRecords({
    [Id = 1, Name = "Hello There"],
    [Id = 2, Name = "Good Bye"]
})