Text.Middle
Characters from the middle of a text, from a position on, forgiving a count that runs past the end.
Group: Text and characters. Power Query M has it too: a query that uses it is written as in Power BI.
Syntax
Text.Middle(text as nullable text, start as number, optional count as nullable number) as nullable text
| Parameter | Type | Description |
|---|---|---|
text | nullable text | The text to work on; null gives null. |
start | number | Where to begin, from 0 for the first character. |
count | nullable number optional | How many characters to take. Left out, to the end. |
Returns
nullable text. The characters asked for, or as many as there are.
Remarks
- Unlike
Text.Range, a count that goes past the end is no error: you get the characters up to the end.
Examples
The postcode in a code
Text.Middle("NO-0150-Oslo", 3, 4)
"0150"
A count past the end
Text.Middle("Oslo", 2, 10)
"lo"