Power Query
Search…
published
Powered By GitBook
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.
1
let
2
tableType = type table [Id = Int32.Type, Name = text],
3
table = Table.FromRecords({[Id = 1, Name = "Hello There"], [Id = 2, Name = "Good Bye"]}),
4
resultTable = Table.AddKey(table, {"Id"}, true)
5
in
6
resultTable
Copied!
Table.FromRecords({[Id = 1, Name = "Hello There"], [Id = 2, Name = "Good Bye"]}, { "Id", "Name" })
Last modified 3yr ago