Type.TableRow

Updated on

Type.TableRow is a Power Query M function that retrieves the row type of a specified table type. The function returns a record type representing the row type of the input table type.

Compatible with: Power BI Service Power BI Desktop Excel Microsoft 365

Syntax

Type.TableRow( table as type ) as type

Description

The Type.TableRow function returns the row type of the specified table type. The result will always be a record type.

Examples

Let’s say you have a simple table type. To extract the type of each row (in the form of a record) you can make use of Type.TableRow:

// Output: type [ myDate = date, Amount = number ]
Type.TableRow( type table [ myDate = date, Amount = number ] )

In case you want to see more details, Type.RecordFields allows you to extract

/* Output:
type [ 
       myDate  = [ Type = type date, Optional = false ], 
       Amount  = [ Type = type number, Optional = false ] 
     ]
*/
let
  myType = type table [ myDate = date, Amount = number ],
  tableRowType = Type.TableRow( myType ),
  RecordFields = Type.RecordFields( tableRowType )
in
  RecordFields

Remember, you can only extract the row type of a table type. If you have a table, you can extract the type using the Value.Type function. The output is a table type which you can feed to Type.TableRow in the following way:

// Output: type [ myDate = date, Amount = number ]
let
  myTable = #table( type table[ myDate = date, Amount = number] , { {#date(2024,1,1), 100} } )
  myTableType = Value.Type( myTable ), 
  tableRowType = Type.TableRow( myTableType ) 
in
    tableRowType

Other functions related to Type.TableRow are:

BI Gorilla Blog

Contribute » | Contributors: Rick de Groot
Microsoft documentation: https://learn.microsoft.com/en-us/powerquery-m/type-tablerow