Table.InsertRows
The function retrieves a table containing rows that have been inserted into the specified position, offset. It is important to note that each column in the row being inserted must have matching column...
The function retrieves a table containing rows that have been inserted into the specified position, offset. It is important to note that each column in the row being inserted must have matching column types with the table.
Example 1
To add a row to a specific position in a table, the following code can be used in Power Query M language:
Table.InsertRows(
Table.FromRecords({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"]
}),
1,
{[CustomerID = 3, Name = "Paul", Phone = "543-7890"]}
)
The output after inserting the row at position 1 would be:
Table.FromRecords({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"]
})
Example 2
To insert two rows into a table at position 1, the following code can be used in Power Query M language:
Table.InsertRows(
Table.FromRecords({[CustomerID = 1, Name = "Bob", Phone = "123-4567"]}),
1,
{
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"]
}
)
The output after inserting the rows at position 1 would be:
T