Splitter.SplitTextByDelimiter

D

T

The M Code Behind the Power Query M function Splitter.SplitTextByDelimiter

In this article, we will take a closer look at the M code behind the Splitter.SplitTextByDelimiter function, how it works, and how you can use it to split text values in your data.

What is Splitter.SplitTextByDelimiter?

The Splitter.SplitTextByDelimiter function is a built-in function in Power Query that enables users to split a text value into multiple values based on a specified delimiter. The function returns a list of values resulting from the split operation.

The M Code Behind Splitter.SplitTextByDelimiter

The M code behind the Splitter.SplitTextByDelimiter function is relatively straightforward. The function takes three arguments: the text value to split, the delimiter character(s), and an optional parameter that specifies how many splits to perform.

Here is the M code for the Splitter.SplitTextByDelimiter function:


(text as text, delimiter as text, optional limit as nullable number) as list


The first argument, “text”, is the text value that you want to split. The second argument, “delimiter”, is the character or characters that you want to use as the delimiter. If you want to split the text value based on a comma delimiter, for example, you would specify “,” as the delimiter.

The third argument, “limit”, is an optional parameter that specifies how many splits to perform. If you omit this parameter, the function will split the text value based on all occurrences of the delimiter.

How to Use Splitter.SplitTextByDelimiter

To use the Splitter.SplitTextByDelimiter function, you first need to load your data into Power Query. Once your data is loaded, you can add a new column to your query that uses the Splitter.SplitTextByDelimiter function to split a text value.

Here is an example of how to use Splitter.SplitTextByDelimiter:

1. Load your data into Power Query.

2. Click on the “Add Column” tab in the Power Query Editor.

3. Click on “Custom Column” in the “Add Column” dropdown menu.

4. Enter a name for your new column.

5. In the “Custom Column Formula” dialog box, enter the following M code:


Splitter.SplitTextByDelimiter([Text Value],",")


6. Replace “Text Value” with the name of the column that contains the text value that you want to split.

7. Click OK.

Once you have added the new column, Power Query will split the text value based on the specified delimiter and return a list of values in the new column.

The Splitter.SplitTextByDelimiter function is a powerful tool in Power Query that enables users to split text values into multiple values based on a specified delimiter. By understanding the M code behind the function, you can use it to transform your data and make it more suitable for analysis.

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)