Text.Reverse

Updated on

Text.Reverse is a Power Query M function that reverses the characters in a given text value. The function returns the reversed text value.

Compatible with: Power BI Service Power BI Desktop Excel Microsoft 365

Syntax

Text.Reverse( text as nullable text ) as nullable text

Description

The function takes a text string as an input – this can be any text that you want to reverse. The term “nullable” indicates that this function can also accept a null value as an input. As for the output, the function returns the reversed string, or in case of a null input, it simply returns null.

Examples

Now, let’s see how the Text.Reverse function behaves when we use it in a practical scenario.

For instance, consider the string “Power Query”. We want to reverse this, making it “yreuQ rewoP”. So, we would use the Text.Reverse function as follows:

Text.Reverse( "Power Query" ) // Output: yreuQ rewoP
Text.Reverse to reverse a string

This formula instructs Power Query to reverse the sequence of the characters in “Power Query”. The output, as expected, is “yreuQ rewoP”, the reversed string.

As the syntax suggests, the function accepts null values to. The term “nullable text” indicates this. When you provide the function with a null value, it returns null.

Text.Reverse( null ) // Output: null
Text.Reverse and null values

In summary, the Text.Reverse function is useful for anyone using the Power Query M language, providing a simple way to reverse text strings.

Learn more about Text.Reverse in the following articles:

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