Forum Discussion
Anonymous
6 years agoNot applicable
Set existing column as Primary key (index)
How do we set up existing column in a given table within the model as a primary key? Note that we do not want/need to create an additional index column. We want to tell the model: this column is ...
leonardo_assump
1 year agoRegular Visitor
Oh well. Better late than never, I guess...
In Power Query M, Table.AddKey "adds a key to table, where columns is the list of column names that define the key, and isPrimary specifies whether the key is primary".
Signature: Table.AddKey(table as table, columns as list, isPrimary as logical) as table
Official documentation: https://learn.microsoft.com/en-us/powerquery-m/table-addkey
Right-click last step, select "insert step after",
then edit the new step code replacing `LastStep` (for example) by
Table.AddKey(LastStep, {"SomeColumn", "Maybe Other Column"}, true).