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: 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. No spaces between words are removed. My solution in the post was to apply the Trim command then use the Replace Values command to replace instances of double spaces with single spaces. Then repeat the process until there are no more double spaces. Not a great solution to be honest. It means repeating a step which takes a bit more effort.