Title: Replicate Excel's TRIM Function In Power Query | How To Excel
Headings: Replicate Excel’s TRIM Function In Power Query
Replicate Excel’s TRIM Function In Power Query
Table of Contents
The Problem
Video Tutorial
M Code For The Query Function
Create A Blank Query
Add M Code To The Advanced Editor
Using The Query Function
Conclusions

Content: Replicate Excel's TRIM Function In Power Query | How To Excel
Replicate Excel’s TRIM Function In Power Query
Posted by John | Jan 17, 2019 | Get & Transform, Power Query | 4 |
In this post we’re going to learn how to build a custom query function in power query that will replicate Excel’s TRIM function! If you find you’re always doing the same transformation or calculation, why not turn it into a function? This can simplify the steps in your query and allow you to re-use a solution. Table of Contents
The Problem
Video Tutorial
M Code For The Query Function
Create A Blank Query
Add M Code To The Advanced Editor
Using The Query Function
Conclusions
The Problem
A while ago, I wrote a post on 4 ways to remove unwanted space characters from text data. Two solutions I looked at were the TRIM function in Excel and using Power Query. Excel’s TRIM function is easy to use and does a great job. It will remove all space characters from the start and end of a text string, as well as remove excess spaces between words. So when there’s more than one space between a word, it will replace them with a single space. There is also a Text. Trim function in power query, but it only takes off spaces from the start and end of a text string.