Text.Lower

D

T

The M Code Behind the Power Query M function Text.Lower

Text.Lower is a Power Query M function that takes a text input and returns the same text in lowercase format. In this article, we’ll take a closer look at the M code behind the Text.Lower function and explore some examples of how it can be used.

Understanding the M Code Behind Text.Lower

The M code behind Text.Lower is relatively simple. Here’s what the code looks like:


(Text as text) as text =>

Text.Lower(Text)


Let’s break this down a bit. The first line defines the function signature. It specifies that the function takes a single argument (Text) of type text and returns a value of type text.

The second line is the function body. It simply calls the built-in Text.Lower function and passes in the Text argument.

Examples of Using Text.Lower

Now that we understand how the Text.Lower function works, let’s take a look at some examples of how it can be used.

Example 1: Converting Uppercase Text to Lowercase Text

Suppose we have a column in our data that contains names in all uppercase letters. We can use the Text.Lower function to convert these names to lowercase. Here’s what the code would look like:


= Table.TransformColumns(

Source,

{{"Name", each Text.Lower(_), type text}}

)


This code uses the Table.TransformColumns function to apply the Text.Lower function to the “Name” column in the Source table. The “each” keyword is used to apply the function to each value in the column.

Example 2: Removing Duplicates from a Column

Sometimes we may have a column in our data that contains duplicate values. We can use the Text.Lower function to remove these duplicates and create a unique list of values. Here’s what the code would look like:


= List.Distinct(

Table.Column(

Table.TransformColumns(

Source,

{{"Name", each Text.Lower(_), type text}}

),

"Name"

)

)


This code uses the Table.TransformColumns function to apply the Text.Lower function to the “Name” column in the Source table. It then uses the Table.Column function to extract the “Name” column from the transformed table. Finally, it uses the List.Distinct function to remove any duplicate values.

The Text.Lower function in Power Query M is a simple yet powerful tool for manipulating text data. By understanding the M code behind the function and exploring some examples of its use, we can gain a better understanding of how to work with text data in Power Query.

Power Query and M Training Courses by G Com Solutions (0800 998 9248)

Upcoming Courses

Contact Us

    Subject

    Your Name (required)

    Company/Organisation

    Email (required)

    Telephone

    Training Course(s)

    Your Message

    Upload Example Document(s) (Zip multiple files)