如何在多列的text.combine字段中按数字排序?

问题描述 投票:0回答:1

我有一个生成的报告,其中我基本上“转置”并组合两个单独的列(逆透视、删除重复项、透视、文本.组合、列表.排序)。

我找到了这篇post,其中展示了如何对单个列进行排序。 但是,我不知道如何对两个单独的列进行数字排序。 请问这样可以吗?

原始报告示例:

enter image description here

这是我想要获得的结果: enter image description here

这是我目前拥有的代码。当我尝试添加另一行来对“Division #”列进行排序时,它会取消对“Warehouse Number”列的排序。

let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(Source, {"Case GTIN Number"}, "Attribute", "Value"),
    #"Changed Type" = Table.TransformColumnTypes(#"Unpivoted Columns",{{"Value", type text}}),
    #"Removed Duplicates" = Table.Distinct(#"Changed Type"),
    #"Pivoted Column" = Table.Pivot(#"Removed Duplicates", List.Distinct(#"Removed Duplicates"[Attribute]), "Attribute", "Value",each Text.Combine(_, ",")),
    #"Sort Column" = Table.TransformColumns(#"Pivoted Column",
    {"Warehouse Number", each Text.Combine(List.Sort(Text.Split(_,",")),",")})
in
    #"Sort Column"
excel sorting powerquery unpivot
1个回答
0
投票

尝试

let Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Grouped Rows" = Table.Group(Source, {"Case GTIN Number"}, {
    {"Warehouse Number", each Text.Combine(List.Sort(_[Warehouse Number]),",")},
    {"Division #", each Text.Combine(List.Sort(_[#"Division #"]),",")}
})
in #"Grouped Rows"

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.