Record.ToTable
Converts a record into a two-column table, with one row for each field, a Name column and a Value column.
Record.ToTable(record)Returns: A table with the columns Name and Value.
What it does
Record.ToTable turns one record into a table in which each field becomes a row. The first column holds the field name and the second holds the value. Use it to show the settings, parameters or summary figures of a record in a readable grid, or to make a pivot-friendly list.
Syntax and arguments
record: the record to convert.
Example
A close summary is held as one record of control figures. The reviewer wants it as a list of lines to print in the close pack.
let
ControlFigures = [RowsLoaded = 412, RowsRejected = 3, ControlTotal = 1805.5],
AsTable = Record.ToTable(ControlFigures)
in
AsTable
AsTable has three rows: RowsLoaded with 412, RowsRejected with 3, and ControlTotal with 1805.5. Each control figure now sits on its own line, ready to be reviewed.
Example: a second, different use
Turning a parameter record into a visible table for a parameters sheet, so that users can see the settings a query is using.
Things to watch
- The values can have different types. A column of mixed numbers and text is fine for display, but do not total it.
- The field order is kept, so the table reads the same way as the record.
- To go back to a record, use Record.FromTable on a table with Name and Value columns.
- The columns are always called Name and Value. Rename them afterward if you need other names.
In business terms
Close summaries, control totals and settings for a query can be shown as a list, so that a reviewer reads them in one place. A printed list of control figures is easier to sign off than a long record.