Thực hành Power query sử dụng M-code căn bản trong kế toán
Ứng dụng [URL='www.giaiphapexcel.com/diendan/threads/h%C3%A0m-v%C3%A0-ng%C3%B4n-ng%E1%BB%AF-m-trong-power-query-c%C4%83n-b%E1%BA%A3n.152793/post-1001658']bài số 9 chủ đề Hàm và ngôn ngữ M trong Power query, với file dữ liệu kế toán chuẩn của năm 2008, hãy xem bài thực hành lập sổ quỹ vừa tiền mặt, vừa ngân hàng trong 1 sheet
Sử dụng 2 name ở ô H2 và E3 với H2 chọn giữa tài khoản 111 và 112, E3 chọn tháng, sau đó nhấn refresh
M-Code:
let
MonthRep= Excel.CurrentWorkbook(){[Name="MonthQuy"]}[Content]{0}[Column1] ,
AcctRep = Excel.CurrentWorkbook(){[Name="TKQuy"]}[Content]{0}[Column1] ,
Source = Excel.Workbook(File.Contents("E:DataThanhMyMY BOOKMCode-PowerQueryData-Exercise1.xlsx"), null, true),
Data_DefinedName = Source{[Item="Data",Kind="DefinedName"]}[Data],
#"Promoted Headers" = Table.PromoteHeaders(Data_DefinedName, [PromoteAllScalars=true]),
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"date", type date}, {"loaict", type text}, {"sct", type text},
{"diengiai", type text}, {"TkNo", type text}, {"TKCo", type text}, {"Stien", Int64.Type}, {"Serie", type text},
{"hoadon", Int64.Type}, {"ngaygoc", type date}, {"Msthue", type text}, {"Mskh", type text}, {"TenKH", type text},
{"HD", type logical}, {"LoaiHD", type text}, {"VATRate", Int64.Type}, {"Noidung", type text}, {"MaCP", type text}}),
#"Filtered Rows" = Table.SelectRows(#"Changed Type", each ([TkNo] = AcctRep or [TKCo] = AcctRep)and Date.Month([date]) = MonthRep),
#"Added Custom" = Table.AddColumn(#"Filtered Rows", "TKDU", each if [TkNo] = AcctRep then [TKCo] else [TkNo]),
#"Added Custom1" = Table.AddColumn(#"Added Custom", "Thu", each if [TkNo] = AcctRep then [Stien] else 0),
#"Added Custom2" = Table.AddColumn(#"Added Custom1", "Chi", each if [TKCo]=AcctRep then [Stien] else 0),
#"Added Index" = Table.AddIndexColumn(#"Added Custom2", "Index", 1, 1, Int64.Type),
#"Removed Columns" = Table.RemoveColumns(#"Added Index",{"loaict", "diengiai", "TkNo", "TKCo", "Stien", "Serie", "hoadon", "ngaygoc", "Msthue", "Mskh", "HD", "LoaiHD", "VATRate", "MaCP"}),
#"Reordered Columns" = Table.ReorderColumns(#"Removed Columns",{"Index", "sct", "date", "TenKH", "Noidung", "TKDU", "Thu", "Chi"})
in
#"Reordered Columns"
63716370
M-code
www.giaiphapexcel.com/diendan/threads/th%E1%BB%B1c-h%C3%A0nh-power-query-s%E1%BB%AD-d%E1%BB%A5ng-m-code-c%C4%83n-b%E1%BA%A3n-trong-k%E1%BA%BF-to%C3%A1n.153017/
Khóa học SprinGO phù hợp
Ứng dụng AI và Chat GPT trong Quản trị nhân sự
Học xong khóa này, học viên có thể: Hiểu đúng bản chất AI, các nhóm AI phổ biến và cách AI “hoạt động” ở...
Xem khóa học
Bình luận