Text.At is a Power Query M function that retrieves the character at a specified position within a text value. The function returns the character in the text value at the specified position, with positions starting at 0.
Compatible with: Power BI Service Power BI Desktop Excel Microsoft 365
Syntax
Text.At(
text as nullable text,
index as number,
) as nullable text
Description
The Text.At function retrieves the character at the position index
within the text
parameter and returns it as a text value. It is important to note that positions in the text start from 0, meaning the first character is at position 0, the second character is at position 1, and so on.
Examples
Let’s look at some examples that use the Text.At function.
Suppose you have the text string “Hello, World” and you want to retrieve the character at position 4. By using the Text.At function with the text “Hello, World” and an index of 4, you will obtain “o” as the resulting character.
Text.At( "Hello, World", 4 ) // Returns "o"
The next example uses the text “Run@”. If you need to extract the character at position 3 from this text, you specify an index of 3. This will return “@” as the retrieved character.
Text.At( "Run@", 3 ) // Returns "@"
The last example has the text ” – – – “. You want to retrieve the character at position 1, Text.At with the text ” – – – ” and an index of 1 will give you “-” as the resulting character.
Text.At( " - - - ", 1 ) // Returns "-"
Related articles
Learn more about Text.At in the following articles:
- Text Functions in Power Query M (150+ Examples)
Your guide to Text Functions in Power Query M. Learn from practical examples and master Power Query’s most useful Text functions. » Read more
Related functions
Other functions related to Text.At are:
2023-2024 © BI Gorilla. All rights are reserved. Information from Microsoft docs is property of Microsoft Corp. | Privacy Policy