【问题标题】:Powerquery: split text from different columns to same rowsPowerquery:将文本从不同的列拆分到相同的行
【发布时间】:2020-02-12 09:29:55
【问题描述】:

我有:

column1 | column2 | colum3
a;b;c   | x;y;z   | door;house;tree

使用 Excel powerquery 的期望结果:

 a      | x       | door
 b      | y       | house
 c      | z       | tree

我尝试过: Text.Split([column1],";") 并展开换行,得到:

a
b
c

但是,当尝试对其他值进行相同操作时,会创建新行而不是使用现有行。

【问题讨论】:

    标签: powerquery


    【解决方案1】:

    您可以使用此代码:

    let
        Source = Excel.CurrentWorkbook(){[Name="Table"]}[Content],
        rec = Table.ReplaceValue(Source,0,0,(a,b,c)=>Text.Split(a,";"),{"column1", "column2", "column3"}){0},
        table = #table(Record.FieldNames(rec),List.Zip(Record.FieldValues(rec)))
    in
        table
    

    【讨论】:

    • 它只适用于第一行。但无论如何感谢您的示例,我了解到诀窍的关键是使用“List.Zip”。使用它,我解决了这个问题。谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-12
    • 1970-01-01
    相关资源
    最近更新 更多