List.ReplaceRange Function in Power Query
The List.ReplaceRange function returns a list that replaces count values in a list with a replaceWith list starting at specified position, known as index. The first item in the list has index 0.
Syntax
List.ReplaceRange(list as list, index as number, count as number, replaceWith as list) as list
The parameters of the function are:
- list: It specifies the input list.
- index: The index position at which we want to update the list.
- count: The number of items which are replaced from the given index position.
- replaceWith: The given list which takes place in the input list from the given index.
Example:
Power Query M
let source = {"India", "America", "Canada", "Japan", "Australia", "England", "China"}, return = List.ReplaceRange(source, 2, 4, {"Bhutan", "Nepal"}) in return
The output of the above code is shown below: