Last active
April 19, 2020 18:05
-
-
Save Mike-Honey/82240072383479d219978613342ea548 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Based on Ken Puls' blog post - http://www.excelguru.ca/blog/2015/10/08/clean-whitespace-in-powerquery/ | |
// Trims in the style of the Excel TRIM function - embedded whitespace is trimmed to a single space. | |
// This variation accepts null values in the text parameter, in which case it returns an empty string. | |
(optional text as text, optional char_to_trim as text) => | |
let | |
char = if char_to_trim = null then " " else char_to_trim, | |
text2 = if text = null then " " else text, | |
split = Text.Split(text2, char), | |
removeblanks = List.Select(split, each _ <> ""), | |
result=Text.Combine(removeblanks, char) | |
in | |
result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment