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
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.
Table.Transformation
Add a key to {[Id = 1, Name = "Hello There"], [Id = 2, Name = "Good Bye"]} that comprise of {"Id"} and make it a primary.
lettableType = 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)inresultTable
Table.FromRecords({[Id = 1, Name = "Hello There"], [Id = 2, Name = "Good Bye"]}, { "Id", "Name" })