如何提取 Power BI 查询中分隔符之间的文本
How to Extract the Text between the delimiters in Power BI Query
我想添加一个自定义列来提取分隔符“~”之间的文本
这是输入:
这是我期待的输出:
我试过下面的查询,但它不起作用
=Text.Select([#"Comments"]
{"A".."Z"} & {"1".."10"}&{"~"})
你能推荐我吗
这适用于 powerquery (M)
假设数据来自 Table1,进入 Column 1
如果不正确,请调整代码
它还假定结尾 ~ 和下一个单词之间有一个 space
let Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Replaced Value" = Table.ReplaceValue(Source,"~ ","::",Replacer.ReplaceText,{"Column1"}),
#"Adjust edge case" = Table.TransformColumns(#"Replaced Value",{{"Column1", each if Text.End(_,1)="~" then Text.Start(_,Text.Length(_)-1) &"::" else _, type text}}),
#"Added Custom" = Table.AddColumn(#"Adjust edge case", "Custom", each List.Difference(List.Transform(Text.Split([Column1],"~"), each Text.BeforeDelimiter(_,"::")),{""})),
ColumnNames=List.Transform({1..List.Max(List.Transform(#"Added Custom"[Custom], each List.Count(_)))}, each "Data "&Text.From(_)),
#"Added Custom2" = Table.AddColumn(#"Adjust edge case", "Custom", each Text.Combine(List.Skip(List.Transform(Text.Split([Column1],"~"), each Text.BeforeDelimiter(_,"::")),1),"~")),
#"Split Column by Delimiter" = Table.SplitColumn(#"Added Custom2", "Custom", Splitter.SplitTextByDelimiter("~", QuoteStyle.Csv), ColumnNames)
in #"Split Column by Delimiter"
我想添加一个自定义列来提取分隔符“~”之间的文本
这是输入:
这是我期待的输出:
我试过下面的查询,但它不起作用
=Text.Select([#"Comments"]
{"A".."Z"} & {"1".."10"}&{"~"})
你能推荐我吗
这适用于 powerquery (M)
假设数据来自 Table1,进入 Column 1 如果不正确,请调整代码
它还假定结尾 ~ 和下一个单词之间有一个 space
let Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Replaced Value" = Table.ReplaceValue(Source,"~ ","::",Replacer.ReplaceText,{"Column1"}),
#"Adjust edge case" = Table.TransformColumns(#"Replaced Value",{{"Column1", each if Text.End(_,1)="~" then Text.Start(_,Text.Length(_)-1) &"::" else _, type text}}),
#"Added Custom" = Table.AddColumn(#"Adjust edge case", "Custom", each List.Difference(List.Transform(Text.Split([Column1],"~"), each Text.BeforeDelimiter(_,"::")),{""})),
ColumnNames=List.Transform({1..List.Max(List.Transform(#"Added Custom"[Custom], each List.Count(_)))}, each "Data "&Text.From(_)),
#"Added Custom2" = Table.AddColumn(#"Adjust edge case", "Custom", each Text.Combine(List.Skip(List.Transform(Text.Split([Column1],"~"), each Text.BeforeDelimiter(_,"::")),1),"~")),
#"Split Column by Delimiter" = Table.SplitColumn(#"Added Custom2", "Custom", Splitter.SplitTextByDelimiter("~", QuoteStyle.Csv), ColumnNames)
in #"Split Column by Delimiter"