OpenBI Docs Buy

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
ParameterTypeDescription
textnullable textThe text to work on; null gives null.
offsetnumberWhere to begin, from 0 for the first character.
countnullable 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.Middle when 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]

Text.Middle, Text.At, Text.RemoveRange.

Last updated · OpenBI Studio 0.3.79