List.InsertRange

This function creates a new list by inserting specified values into another list at a specific index position. The index position starts at 0 in the target list. Parameters: - list: The destination l...

Syntax

List.InsertRange(list as list, index as number, values as list) as list

About

This function creates a new list by inserting specified values into another list at a specific index position. The index position starts at 0 in the target list. Parameters: - list: The destination list where the values will be inserted. - index: The position in the target list where the values will be added. The first position is index 0. - values: The values to be inserted into the list.

Explanation

Example 1 To add the list ({3, 4}) into the target list ({1, 2, 5}) at position 2, use the following command: Power Query MList.InsertRange({1, 2, 5}, 2, {3, 4}) The resulting list will be: {1, 2, 3, 4, 5} Example 2 To insert a list with a nested list ({1, {1.1, 1.2}}) into a target list ({2, 3, 4}) at position 0, use the command: Power Query MList.InsertRange({2, 3, 4}, 0, {1, {1.1, 1.2}}) The resulting list will be: {1, {1.1, 1.2}, 2, 3, 4}