Table.Keys is a Power Query M function that retrieves the keys of a specified table. The function returns a list of the table’s keys.
Compatible with: Power BI Service Power BI Desktop Excel Microsoft 365
Syntax
Table.Keys( table as table ) as list
Description
Returns the keys of the specified table.
Examples
Get the list of keys for a table.
// Output: {[Columns = {"Id"}, Primary = true]}
let
table = Table.FromRecords( {
[Id = 1, Name = "Hello There"],
[Id = 2, Name = "Good Bye"]
} ),
tableWithKeys = Table.AddKey( table, {"Id"}, true ),
keys = Table.Keys( tableWithKeys )
in
keys
Related functions
Other functions related to Table.Keys are:
