Power Query
Search…
published
Table
Table.AddKey

Table.AddKey

Add a key to a table, specify the subset of the table?s column names that defines the key, and specify whether the key is primary.
function (table as table, columns as list, isPrimary as logical) as table

Description

Add a key to table, given columns is the subset of table's column names that defines the key, and isPrimary specifies whether the key is primary.

Category

Table.Transformation

Examples

Add a key to {[Id = 1, Name = "Hello There"], [Id = 2, Name = "Good Bye"]} that comprise of {"Id"} and make it a primary.
let
tableType = type table [Id = Int32.Type, Name = text],
table = Table.FromRecords({[Id = 1, Name = "Hello There"], [Id = 2, Name = "Good Bye"]}),
resultTable = Table.AddKey(table, {"Id"}, true)
in
resultTable
Table.FromRecords({[Id = 1, Name = "Hello There"], [Id = 2, Name = "Good Bye"]}, { "Id", "Name" })
Copy link
On this page
Table.AddKey
Description
Category
Examples