Record.Field Function in Power Query
The Record.Field function returns the value of the given field. If the field is not found, an error is thrown.
Syntax
Record.Field(record as record, field as text) as any
Example: Find the value of field "CustomerID" in the record.
Power Query M
Record.Field([CustomerID = 3, Name = "Alia", Phone = "543-7890"], "CustomerID")
The output will be 3.
Example:
Power Query M
let MyTable = Table.FromRecords( { [CustomerID = 1, Name = "Ashish", Phone = "123-4567"], [CustomerID = 2, Name = "Katrina", Phone = "987-6543"], [CustomerID = 3, Name = "Alia", Phone = "543-7890"], [CustomerID = 4, Name = "Vicky", Phone = "676-8479"], [CustomerID = 5, Name = "Mohini", Phone = "574-8864"], [CustomerID = 6, Name = "Meenakshi", Phone = "574-8864"], [CustomerID = 7, Name = "Esha", Phone = "574-8864"], [CustomerID = 8, Name = "Anjali", Phone = "574-8864"] } ), ReturnFieldValue = Record.Field(MyTable{2}, "Name") in ReturnFieldValue
The output will be “Alia”.
Example:
Power Query M
let MyTable = Table.FromRecords( { [CustomerID = 1, Name = "Ashish", Phone = "123-4567"], [CustomerID = 2, Name = "Katrina", Phone = "987-6543"], [CustomerID = 3, Name = "Alia", Phone = "543-7890"], [CustomerID = 4, Name = "Vicky", Phone = "676-8479"], [CustomerID = 5, Name = "Mohini", Phone = "574-8864"], [CustomerID = 6, Name = "Meenakshi", Phone = "574-8864"], [CustomerID = 7, Name = "Esha", Phone = "574-8864"], [CustomerID = 8, Name = "Anjali", Phone = "574-8864"] } ), ReturnFieldValue = Record.Field(MyTable{2}, "Education") in ReturnFieldValue
The output is shown in the following image: