如何用最简洁的语句完成以下拆分(越简洁实用越好)
如何用最简洁的语句完成以下拆分(越简洁实用越好)
一样的,换汤不换药,短不了,供参考。
= #table( {"明细科目","类别","项目","备注","币种"},
Table.ToList( 源, each List.Skip(List.RemoveItems(Text.SplitAny(_{0},"()-|币别:"),{""}))))
或者
= Table.SplitColumn( 源,
"明细科目",
each List.Skip(List.RemoveItems(Text.SplitAny(_,"()-|币别:"),{""})),
{"明细科目","类别","项目","备注","币种"} )
@Able
不好意思,翻车了。谢谢找出错误。
Text.SplitAny是见啥都拆,比如“币别”,只要是“币”或者“别”都会拆,所以这里币别和人民币这里都拆了。SplitTextByAnyDelimiter是把“币别”作为一个整体拆,所以只拆“币别”,不会拆“人民币”。
改一下就可以了:
= #table( {"明细科目","类别","项目","备注","币种"},
Table.ToList( 源, each List.Skip(List.RemoveItems(Text.SplitAny(_{0},"()-|别:"),{"","币"}))))
或者
= Table.SplitColumn( 源,
"明细科目",
each List.Skip(List.RemoveItems(Text.SplitAny(_,"()-|别:"),{"","币"})),
{"明细科目","类别","项目","备注","币种"} )
或者你把each 后边的部分换成 each Splitter.SplitTextByAnyDelimiter(delimiters as list)({0}) 或者() 试试
这个下划线 怎么自动不见了
Table.ToList(源,each Splitter.SplitTextByAnyDelimiter(delimiters as list)(_{0}))
或者
Table.SplitColumn(源,"明细科目",each Splitter.SplitTextByAnyDelimiter(delimiters as list)(_),{列名})