Text.Range
Characters from a position of a text on, strictly inside the text.
Group: Text and characters. Power Query M has it too: a query that uses it is written as in Power BI.
Syntax
Text.Range(text as nullable text, offset as number, optional count as nullable number) as nullable text
| Parameter | Type | Description |
|---|---|---|
text | nullable text | The text to work on; null gives null. |
offset | 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; an error when they reach past the end.
Remarks
- Use
Text.Middlewhen the text may be shorter than you expect.
Examples
The postcode in a code
Text.Range("NO-0150-Oslo", 3, 4)
"0150"
From a position to the end
Text.Range("NO-0150-Oslo", 8)
"Oslo"
Past the end
Text.Range("Oslo", 2, 5)
Result: an error.
[Reason = "Expression.Error", Message = "The 'count' argument is out of range.", Detail = null]