Record.FieldNames is a Power Query M function that extracts the names of the fields in a record as text. The function returns a list containing the names of all the fields in the input record.
Compatible with: Power BI Service Power BI Desktop Excel Microsoft 365
Syntax
Record.FieldNames( record as record ) as list
Description
The Record.FieldNames
function extracts all the field names from a given record
and returns them as a list.
Examples
To retrieve all field names from a record, you can use the following code:
// Output: { "Citrus", "Berry", "StoneFruit" }
Record.FieldNames( [ Citrus = "Orange", Berry = "Strawberry", StoneFruit = "Peach" ] )
In this example, the Record.FieldNames
function takes a record with three fields: Citrus
, Berry
, and StoneFruit
. The function retrieves these field names and returns them as a list. This is what it looks like:
The Record.FieldNames
function is particularly useful for working with logic that depends on field names. For example, you may want to sort your values in a particular order. To do that you could first retrieve them using the Record.FieldNames
function and then pass it to List.Sort.
You could say that Record.FieldNames
is the record equivalent of the Table.ColumnNames function, which retrieves column names from a table. Both functions help you when creating dynamic logic based on field or column names.
Related functions
Other functions related to Record.FieldNames are:
2023-2024 © BI Gorilla. All rights are reserved. Information from Microsoft docs is property of Microsoft Corp. | Privacy Policy