Table.ReplaceRows
Takes out a run of rows at a position and puts other rows in their place.
Group: Table. Power Query M has it too: a query that uses it is written as in Power BI.
Syntax
Table.ReplaceRows(table as table, offset as number, count as number, rows as list) as table
| Parameter | Type | Description |
|---|---|---|
table | table | The table to change. |
offset | number | The position of the first row to take out, counting from 0. |
count | number | How many rows to take out. |
rows | list | The rows to put in, as records with the table's columns: more or fewer than count is fine. |
Returns
table. The rows before the run, the new rows, then the rows after it.
Examples
One row out, two in
Table.ReplaceRows(
#table({"Product", "Price"}, {{"Chair", 50}, {"Desk", 120}, {"Lamp", 30}}),
1, 1,
{[Product = "Desk", Price = 110], [Product = "Shelf", Price = 75]})
| Product | Price |
|---|---|
| Chair | 50 |
| Desk | 110 |
| Shelf | 75 |
| Lamp | 30 |
Related functions
Table.InsertRows, Table.RemoveRows, Table.ReplaceMatchingRows.