OpenBI Docs Buy

Table.InsertRows

Puts new rows into a table at a position you give.

Group: Table. Power Query M has it too: a query that uses it is written as in Power BI.

Syntax

Table.InsertRows(table as table, offset as number, rows as list) as table
ParameterTypeDescription
tabletableThe table to add to.
offsetnumberWhere the new rows go: 0 before the first row, the row count after the last.
rowslistThe new rows as records, with the table's column names as their fields.

Returns

table. The table with the new rows at that position.

Remarks

  • An offset beyond the end of the table is an error.
  • To add rows at the end, Table.Combine with a second table does the same.

Examples

A product in second place

let
    Lines = #table({"Product", "Price", "Units"}, {{"Chair", 50, 4}, {"Desk", 120, 1}, {"Lamp", 30, 6}})
in
    Table.InsertRows(Lines, 1, {[Product = "Sofa", Price = 400, Units = 1]})
ProductPriceUnits
Chair504
Sofa4001
Desk1201
Lamp306

Two rows at the end

let
    Lines = #table({"Product", "Price", "Units"}, {{"Chair", 50, 4}, {"Desk", 120, 1}, {"Lamp", 30, 6}})
in
    Table.InsertRows(Lines, 3, {[Product = "Rug", Price = 80, Units = 2], [Product = "Shelf", Price = 60, Units = 3]})
ProductPriceUnits
Chair504
Desk1201
Lamp306
Rug802
Shelf603

Table.Combine, Table.ReplaceRows, Table.RemoveRows, Table.FromRecords.

Last updated · OpenBI Studio 0.3.79