Home » Power Query M Functions » Text.Combine – Power Query M Function

Text.Combine – Power Query M Function

Text combine Output

The Text.Combine function in Power Query’s M language is used to combine multiple text values into a single text value, optionally separated by a specified delimiter.

Let’s get stated-

Download the sample Dataset from below link-

Requirement-

How to combine multiple text column values  such as – Country, State & City values into one column.

Follow the steps below-

Step-1: Go to the Home Tab of Power BI Desktop and Open Power Query Editor  window by selecting “Transform data” option.

Step-2: In the Queries pane,  select the “Orders” table.

Step-3: In the Home tab, click on “Add Column”  and choose “Custom Column”.

Step-4: In the “Custom Column” dialog box, provide a name for the new column, exp- “Combine”.



Step-5: In the “Custom column formula” box, enter the following expression, and click on “OK” to create the new column.

Text.Combine({[Country], [State], [City]}, ", ")
Text Combine

Text Combine

After applying the changes, you will see a new column named “Combine” in the table, which contains the combined text value of the “Country”, “State”, and “City” columns, separated by commas.

Text combine Output

Text combine Output



How to combine Text and Number values in Power Query?

You can not directly combine the Text and Number datatype values together using Text.Combine function.

For that you have to use Text.From function which will convert the Sales value to text format.

Text.Combine({[Product Name], Text.From([Sales])}, " - ")
Text From M Function

Text From M Function

Hope you enjoyed the post. Refer more M functions Tutorials

Leave a Reply