Forum Discussion

charl_cfm's avatar
charl_cfm
New Member
2 years ago
Solved

Alphabetic M-Code list

Below is the M-Code in Power Query for removing columns (this is from a model that I am using). Is it possible to arrange the list alphabetically for ease of future reference?   Table.RemoveColumns...
  • spinfuzer's avatar
    2 years ago

    I am not sure if there is a slicker way, but you can create a blank query and use List.Sort and Text.Combine like below

     

     

    let
        Source = Text.Combine(
            List.Sort(
                {"StockItem_ID","VatRateID", "VatRatePerc", "VatValue", "PriceIncl", "TotalVAT", "TotalIncl", "Category_ID", "Category_Code", "Category", "Subcategory_ID", "Subcategory_Code", "Subcategory1_ID", "Subcategory1_Code", "Variety_ID", "Variety_Code", "Packing_ID", "Packing_Code", "Size_ID", "Size_Code", "Grade_ID", "Grade_Code", "ProdAllocationID", "ProdAllocationCode","PriceExclDiscounted", "UOM_ID", "Supplier_Group_ID", "Supplier_Group_Code", "Supplier_Group", "Supplier_Group_Price_ID", "Supplier_Group_Price_Period_Start", "Supplier_Group_Price_Period_End", "Price_Per_Outer_Pack", "TotalCalculation", "Costing_Type", "Price_Per_kg","Subcategory", "Subcategory1", "Variety", "Packing", "Size", "Grade", "PackSize","Std_Wgt_Per_Outer_Pack", "Price_Week","Origin_Doc_Line_ID"}
            ), 
            ", "
        )
    in
        Source

     

     

    Then copy and paste the output into your query.