List.ReplaceRange

Substitutes the numerical values in the designated list with the new values provided in the replaceWith list, beginning at the specified index position.

Syntax

List.ReplaceRange(list as list, index as number, count as number, replaceWith as list) as list

About

Substitutes the numerical values in the designated list with the new values provided in the replaceWith list, beginning at the specified index position.

Explanation

Substitute the values {7, 8, 9} in the list {1, 2, 7, 8, 9, 5} with {3, 4}. To execute this operation, use the Power Query MList.ReplaceRange function as shown below: MList.ReplaceRange({1, 2, 7, 8, 9, 5}, 2, 3, {3, 4}) The resulting list will be {1, 2, 3, 4, 5}.