Table.AddKey

A new key is inserted into a table. The 'columns' parameter should contain the list of column names that will form the key, while the 'isPrimary' parameter indicates if it is a primary key.

Syntax

Table.AddKey(table as table, columns as list, isPrimary as logical) as table

About

A new key is inserted into a table. The 'columns' parameter should contain the list of column names that will form the key, while the 'isPrimary' parameter indicates if it is a primary key.

Explanation

Insert a unique identifier column as the primary key in a table. Usage: Power Query Mlet table = Table.FromRecords({ [Id = 1, Name = "Hello There"], [Id = 2, Name = "Good Bye"] }), resultTable = Table.AddKey(table, {"Id"}, true) in resultTable Output Table.FromRecords({ [Id = 1, Name = "Hello There"], [Id = 2, Name = "Good Bye"] })