Text.At

Updated on

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 "-"

Learn more about Text.At in the following articles:

Other functions related to Text.At are:

Contribute » | Contributors: Rick de Groot
Microsoft documentation: https://learn.microsoft.com/en-us/powerquery-m/text-at

2023-2024 © BI Gorilla. All rights are reserved. Information from Microsoft docs is property of Microsoft Corp. | Privacy Policy