M語言簡單示例--加載多個相同格式的文件到一個文件中

1.先打開文件夾中的其中一個文件
2.啓動編輯器,做相應的基礎轉換操作
3.點擊-視圖,點擊-高級編輯器
4.添加函數,修改函數中的路徑和文件名,即高亮部分
let
    源 = Excel.Workbook(File.Contents("C:\Users\DengXiaoju\Desktop\Sample Files\Chapter 12\test\WEST.XLS"), null, true),
    MySheet1 = 源{[Name="MySheet"]}[Data],
    提升的標題 = Table.PromoteHeaders(MySheet1, [PromoteAllScalars=true]),
    更改的類型 = Table.TransformColumnTypes(提升的標題,{{"Region", type text}, {"Market", type text}, {"Branch_Number", Int64.Type}, {"Customer_Name", type text}, {"State", type text}, {"Effective_Date", type text}, {"Product_Description", type text}, {"Revenue", type number}, {"TransactionCount", Int64.Type}}),
    刪除的列 = Table.RemoveColumns(更改的類型,{"Branch_Number"})
in
    刪除的列
5.修改函數
let GetMyFiles=(FilePath, FileName) =>
let
    源 = Excel.Workbook(File.Contents("C:\Users\DengXiaoju\Desktop\Sample Files\Chapter 12\test\WEST.XLS"), null, true),
    MySheet1 = 源{[Name="MySheet"]}[Data],
    提升的標題 = Table.PromoteHeaders(MySheet1, [PromoteAllScalars=true]),
    更改的類型 = Table.TransformColumnTypes(提升的標題,{{"Region", type text}, {"Market", type text}, {"Branch_Number", Int64.Type}, {"Customer_Name", type text}, {"State", type text}, {"Effective_Date", type text}, {"Product_Description", type text}, {"Revenue", type number}, {"TransactionCount", Int64.Type}}),
    刪除的列 = Table.RemoveColumns(更改的類型,{"Branch_Number"})
in
    刪除的列
in  GetMyFiles
6.-查詢設置位置重命名函數爲fnGetMyFiles1
7.-添加列-自定義列,輸入函數
=fnGetMyFiles1([Folder Path],[Name])
8.展開列
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章