如何在 power bi 中的文本之间 trim 白色 space?
How to trim white space between text in power bi?
我有一列随机文本,字符和字符串之间有随机数量的白色 space。我知道如何 trim 前导和尾随白色 space 我想我知道如何去除所有白色 space 但我正在努力去除多余的白色 space。这是我的专栏的一个例子:
Column1
I have too much space
123 big gap 456
asdfg 2z1xc2 .
我想创建一个新列或将当前列转换为如下所示:
Coumn1
I have too much space
123 big gap 456
asdfg 2z1xc2 .
提前致谢!
要在查询编辑器中执行此操作,我建议使用 Ken Puls:
的方法
(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
如博客 post 中所述,它按指定字符拆分文本字符串(space 是默认值),删除列表中的所有空白元素,然后将列表转换回来成一个字符串。
我有一列随机文本,字符和字符串之间有随机数量的白色 space。我知道如何 trim 前导和尾随白色 space 我想我知道如何去除所有白色 space 但我正在努力去除多余的白色 space。这是我的专栏的一个例子:
Column1
I have too much space
123 big gap 456
asdfg 2z1xc2 .
我想创建一个新列或将当前列转换为如下所示:
Coumn1
I have too much space
123 big gap 456
asdfg 2z1xc2 .
提前致谢!
要在查询编辑器中执行此操作,我建议使用 Ken Puls:
的方法(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
如博客 post 中所述,它按指定字符拆分文本字符串(space 是默认值),删除列表中的所有空白元素,然后将列表转换回来成一个字符串。