删除最前面的横杠(Power Query)
问题:一列数据存在若干横杠,只需要删除第一个文字前的横杠。
思路一:
let
源 = Excel.CurrentWorkbook(){[Name="表2"]}[Content],
每个单元格一个字符 = Table.SplitColumn(源, "列1", Splitter.SplitTextByRepeatedLengths(1), {"列1.1", "列1.2", "列1.3", "列1.4", "列1.5", "列1.6", "列1.7", "列1.8", "列1.9", "列1.10", "列1.11"}),
每行转列表 = Table.FromList(Table.ToRows(每个单元格一个字符), Splitter.SplitByNothing()),
#"去除最前面的-" = Table.TransformColumns(每行转列表, {"Column1", each List.Skip(_, (x)=> x="-" ) } ),
提取值 = Table.TransformColumns(#"去除最前面的-", {"Column1", each Text.Combine(List.Transform(_, Text.From)), type text})
in
提取值
思路二:
let
源 = Excel.CurrentWorkbook(){[Name="表1"]}[Content],
横杠替换为空格 = Table.ReplaceValue(源,"-"," ",Replacer.ReplaceText,{"列1"}),
去除前导空格 = Table.TransformColumns(横杠替换为空格,{"列1", each Text.TrimStart(_)}),
空格替换为横杠 = Table.ReplaceValue(去除前导空格," ","-",Replacer.ReplaceText,{"列1"})
in
空格替换为横杠