The Power Query Text function Text.RemoveRange is used to remove a specified number of characters from a text, starting at a specified position.
Syntax
Text.RemoveRange(text as nullable text, offset as number, optional count as nullable number) as nullable text
- text: This is the text value from which you want to remove characters.
- offset: It specifies the starting position from where characters should be removed. It starts from position 0.
- count: This is the number of characters to be removed from the text value. The default value for count is 1.
Lets understand with the help of an example.
Remove 5 characters starting from position 10 from text “Microsoft Power Query”
For this, we can write below Power Query M code.
Text.RemoveRange([Desc],10,5)
Output: “Microsoft Query”
Note that: If you do not provide the Count value then function takes default value that is 1 and remove only 1 character starting from position 10 from text “Microsoft Power Query”
You can see the output without count value, it takes default count value 1.
Text.RemoveRange([Desc],10)
Output:“Microsoft ower Query”
Remove 5 characters starting from position 0 from text “Microsoft Power Query”
For this, we can write below Power Query M code.
Text.RemoveRange([Desc],0,5)
Output:“soft Power Query”
Also Read..
Text.Remove function: Remove characters from string Power Query
How to extract first and last characters from string Power Query