Last active
March 7, 2024 13:03
-
-
Save IvanBond/de5d947421fbfaaf0e8e45c628b01836 to your computer and use it in GitHub Desktop.
PowerTrim function for Power Query
This file contains hidden or 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
/* | |
Function removes double presents of specified characters. | |
By default remove double spaces and leading + ending spaces. | |
Like TRIM function in Excel | |
Original is taked from Ken Puls's blog | |
http://www.excelguru.ca/blog/2015/10/08/clean-whitespace-in-powerquery/ | |
*/ | |
// part of repository: https://github.com/IvanBond/pquery | |
(text as text, optional char_to_trim as text) => | |
let | |
char = if char_to_trim = null then " " else char_to_trim, | |
split = Text.Split(text, 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