Excel:安裝基礎列表

Excel:安裝基礎列表

預先感謝您幫助我!
您建議我如何從這張表開始:

Equipment Desc | Ship To Name
------------------+----------
Small             | Bob
Small             | Dylan
Small             | Joe 
Small             | Ethan
Small             | Bob   
Medium            | Joe
Medium            | Michael
Medium            | Bob    
Big               | Bob   
Big               | Joe
Big               | Michael

到這張表:

Ship To Name | Equipment Desc
-------------+-------------
Bob          | 1 Big, 1 Medium, 2 small 
Dylan        | 1 Small
Joe          | 1 Big, 1 Medium, 1 Small
Ethan        | 1 Small
Michael      | 1 Big, 1 Medium

我嘗試了舊帖子中的 powerquery 解決方案。 https://superuser.com/a/1054653/1136022
這是我的看法

= Table.Group(#"Changed Type", {"Ship To Name"}, {{"Installed Base", each Text.Combine([Equipment Desc], "#(cr)"), type text}})

但它並沒有總結這些工具。它僅返回儀器列表。
即它不顯示“2 大”而是“1 大,1 大”。

預先感謝您的考慮。

此致,

湯瑪斯

答案1

這應該會讓你相當接近,本質上是:

  • 透過計數進行分組
  • 合併列以合併計數和設備描述
  • 以設備描述為中心
  • 合併列

看起來您的前面的步驟也被命名為#“Changed Type”,所以您應該能夠從那時開始貼上我的程式碼。整合別人的 M 程式碼總是有點繁瑣。

let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCs5NzMlR0lFyyk9SitVB8F0qcxLzUES88lMVUARcSzLQlMAM8U1NySzNRdYDF/HNTM5ITM1BFYTpc8pMx+DBjYBw4fpjAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [#"Equipment Desc" = _t, #"Ship To Name" = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Ship To Name", type text}, {"Equipment Desc", type text}}),
        #"Grouped Rows" = Table.Group(#"Changed Type", {"Ship To Name", "Equipment Desc"}, {{"Count", each Table.RowCount(_), type number}}),
        #"Duplicated Column" = Table.DuplicateColumn(#"Grouped Rows", "Equipment Desc", "Equipment Desc - Copy"),
        #"Merged Columns" = Table.CombineColumns(Table.TransformColumnTypes(#"Duplicated Column", {{"Count", type text}}, "en-AU"),{"Count", "Equipment Desc - Copy"},Combiner.CombineTextByDelimiter(" ", QuoteStyle.None),"Merged"),
        #"Sorted Rows" = Table.Sort(#"Merged Columns",{{"Equipment Desc", Order.Ascending}}),
        #"Pivoted Column" = Table.Pivot(#"Sorted Rows", List.Distinct(#"Sorted Rows"[#"Equipment Desc"]), "Equipment Desc", "Merged"),
        #"Merged Columns1" = Table.CombineColumns(#"Pivoted Column",{"Big", "Medium", "Small"},Combiner.CombineTextByDelimiter(", ", QuoteStyle.None),"Equipment Desc")
 in
        #"Merged Columns1"

答案2

這是一個方法:

  • 按兩列分組RowCount
  • <space>使用分隔符合併設備和計數列
  • 按名稱列分組All Rows
  • 新增自訂列以將結果表轉換為列表
    • 自訂列公式:=Table.Column([Equipment],"Merged")
  • 從列中提取值List(使用雙頭箭頭)並,作為分隔符

let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Equipment Desc", type text}, {"Ship To Name", type text}}),
    #"Trimmed Text" = Table.TransformColumns(#"Changed Type",{{"Ship To Name", Text.Trim, type text}, {"Equipment Desc", Text.Trim, type text}}),
    #"Grouped Rows" = Table.Group(#"Trimmed Text", {"Ship To Name", "Equipment Desc"}, {{"Count", each Table.RowCount(_), type number}}),
    #"Merged Columns" = Table.CombineColumns(Table.TransformColumnTypes(#"Grouped Rows", {{"Count", type text}}, "en-US"),{"Count", "Equipment Desc"},Combiner.CombineTextByDelimiter(" ", QuoteStyle.None),"Merged"),
    #"Grouped Rows1" = Table.Group(#"Merged Columns", {"Ship To Name"}, {{"Equipment", each _, type table [Ship To Name=text, Merged=text]}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows1", "Eqpt List", each Table.Column([Equipment],"Merged")),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Equipment"}),
    #"Extracted Values" = Table.TransformColumns(#"Removed Columns", {"Eqpt List", each Text.Combine(List.Transform(_, Text.From), ", "), type text})
in
    #"Extracted Values"

在此輸入影像描述

相關內容