答案 0 :(得分:1)
假设您的输入表名为Table1,您有一个标题为“a”和“b”的标题行,并且您希望拆分为“,”,那么我的方法似乎有效: (a)删除b并拆分a然后添加索引(b)删除a并拆分b然后添加索引(c)组合部分a和b(d)选择索引列和unpivot其他列删除空值(e)选择索引列和用于组合零件的旋转(f)转换整个表以返回原始行/列视图
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Removed Columns" = Table.RemoveColumns(Source,{"a"}),
#"Split Column by Delimiter" = Table.ExpandListColumn(Table.TransformColumns(#"Removed Columns", {{"b", Splitter.SplitTextByDelimiter(", ", QuoteStyle.None), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "b"),
#"Index" = Table.AddIndexColumn(#"Split Column by Delimiter", "Index", 1, 1),
#"Removed Columns1" = Table.RemoveColumns(Source,{"b"}),
#"Split Column by Delimiter2" = Table.ExpandListColumn(Table.TransformColumns(#"Removed Columns1", {{"a", Splitter.SplitTextByDelimiter(", ", QuoteStyle.None), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "a"),
#"Index2" = Table.AddIndexColumn(#"Split Column by Delimiter2", "Index", 1, 1),
#"Consolidated" = #"Index" & #"Index2",
#"Unpivoted Other Columns" = Table.UnpivotOtherColumns(Consolidated, {"Index"}, "Attribute", "Value"),
#"Pivoted Column" = Table.Pivot(Table.TransformColumnTypes(#"Unpivoted Other Columns", {{"Index", type text}}), List.Distinct(Table.TransformColumnTypes(#"Unpivoted Other Columns", {{"Index", type text}})[Index]), "Index", "Value"),
#"Transposed Table" = Table.Transpose(#"Pivoted Column"),
#"Promoted Headers" = Table.PromoteHeaders(#"Transposed Table", [PromoteAllScalars=true])
in #"Promoted Headers"
答案 1 :(得分:0)
另一个选项是使用Table1
作为来源:
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Transposed Table" = Table.Transpose(Source),
SelectAllColumns = Table.ColumnNames(#"Transposed Table"),
#"Merged Columns" = Table.CombineColumns(#"Transposed Table", SelectAllColumns, Combiner.CombineTextByDelimiter(", ", QuoteStyle.None),"Merged"),
#"Split Column by Delimiter" = Table.SplitColumn(#"Merged Columns", "Merged", Splitter.SplitTextByDelimiter(", ", QuoteStyle.Csv)),
#"Transposed Table1" = Table.Transpose(#"Split Column by Delimiter")
in
#"Transposed Table1"