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

Understanding the Function

Before we dive into the M code, let’s first understand how the function works. The Splitter.SplitTextByAnyDelimiter function takes two arguments: the text to be split and a list of delimiters. The function splits the text into columns based on any of the delimiters in the list.

For example, if we have the text “apple,banana,orange” and we want to split it into columns using the delimiters “,” and “-“, we can use the following M code:

Splitter.SplitTextByAnyDelimiter("apple,banana-orange", {",","-"})

This will result in a table with three columns: “apple”, “banana”, and “orange”.

Breaking Down the M Code

Now that we understand how the Splitter.SplitTextByAnyDelimiter function works, let’s take a closer look at the M code behind it. The function is defined as follows:

( text as text, delimiters as list ) as list

The function takes two arguments: “text” and “delimiters”. “Text” is the text to be split and “delimiters” is a list of delimiters to use when splitting the text.

The M code for the Splitter.SplitTextByAnyDelimiter function is as follows:


splitText = (text as text, delimiters as list) as list =>






each Text.Length(_) > 0




The M code begins with a “let” statement, which defines the splitText function. This function takes two arguments: “text” and “delimiters”.

The function then uses the Text.SplitAny function to split the text into a list of strings using the delimiters specified. The List.Select function is then used to filter out any empty strings from the list.

The Splitter.SplitTextByAnyDelimiter function is an extremely useful tool when working with delimited text files in Power Query. By understanding the M code behind the function, you can gain a better understanding of how it works and how you can modify it to suit your needs.

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

Upcoming Courses

Contact Us


    Your Name (required)


    Email (required)


    Training Course(s)

    Your Message

    Upload Example Document(s) (Zip multiple files)