If we want to use the Excel LEN Function to get the length of strings, it is not supported in M.
Let us see how to use the LEN Function in M to get the length of strings.
Get The Length Of Strings Using M
Step 1: Select the Name Column
First, load the data table in Power Query and select the Name column as shown in the below picture. Here, our aim is to get the length of the string from the Name column.
Step 2: Add Custom Column
Add a custom Column to write a query in M languagefor getting the length of string from Name Column. To use a Custom Column feature, go to-
Add Column > Custom Column
Step 3: Get the Length of String using M Language
To get the length of string we have to create a simple M expression.
In the New column name text box, we have written Name (Len).
Now, you can write the M query as given below:
Text. Length formula is used to get the length of the Name column
Click OK to apply.
Step 4: Close & Apply
Close & Apply the Power Query changes after you get the new column added showing the length of string for Name column as given in below picture.
You can learn more:
- Use Excel’s Right Function With M To Extract Right Side Data
- Use Excel’s Right Function With M To Extract Left Side Data
- Main Ways to Replicating Excel’s Find Function With ‘M’
- Top 5 Ways to Concatenate Datausing ‘M’ in Power Query