Table.InsertRows is a Power Query M function that returns a table with a list of rows inserted into the table at a given position. The function returns a table with the new rows inserted at the specified offset.
Compatible with: Power BI Service Power BI Desktop Excel Microsoft 365
Syntax
Table.InsertRows(
table as table,
offset as number,
rows as list,
) as table
Description
Table.InsertRows inserts a list of rows, rows
, into the table
at a specified position, offset
. Each inserted row must match the column types of the table.
Examples
Insert the row into the table at position 1.
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"]}
)
/* Output:
Table.FromRecords( {
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"]
} )
*/
Insert two rows into the table at position 1.
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"]
}
)
/* Output:
Table.FromRecords( {
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"]
} )
*/
Related articles
Learn more about Table.InsertRows in the following articles:
- Manually Insert Rows to a Table in Power Query
Learn how to insert rows into a table in Power Query. Useful for creating journal entries, or adding additional information. » Read more
Related functions
Other functions related to Table.InsertRows are:
- Table.AlternateRows
- Table.Distinct
- Table.Range
- Table.RemoveFirstN
- Table.RemoveLastN
- Table.RemoveMatchingRows
- Table.RemoveRows
- Table.Repeat
- Table.Skip
2023-2024 © BI Gorilla. All rights are reserved. Information from Microsoft docs is property of Microsoft Corp. | Privacy Policy