Text.RemoveRange Function in Power Query

The Text.RemoveRange function in Power Query is used to remove a range of characters from the given text string, starting at a specified position and for a specified length.

Syntax

Text.RemoveRange(
    text as nullable text, 
    offset as number, 
    optional count as nullable number
) as nullable text 

The function has the following parameters:

Returns: A new text value with the specified range of characters removed.

Example: Remove one character starting at position 2.

Power Query M

let
    Source = Text.RemoveRange("Ashish Coder", 2, 1)
in
    Source  

The output of the above code is "Asish Coder".

Example: Offset out of range.

Power Query M

let
    Source = Text.RemoveRange("Ashish Coder", 50, 8)
in
    Source  

The output of the above code is:

Expression.Error: The 'offset' argument is out of range.
Details:
    50   

Example: Count out of range.

Power Query M

let
    Source = Text.RemoveRange("Ashish Coder", 5, 8)
in
    Source  

The output of the above code is:

Expression.Error: The 'count' argument is out of range.
Details:
    8