Kính gửi AC,
em đang học làm báo cáo power query.
em viết code m để tính số tồn cuối của tháng trước là số dư đầu kỳ của tháng sau theo điều kiện kho=kho, ma=ma, index=index-1
==>kết quả cũng tạm được như ý muốn(em moi hoc nên viết như vậy).
dữ liệu có hơn 5000 dòng như file nó loade dư liệu 20 chưa xong.
Nhờ các AC giúp em có cách nào cho nó tính nhanh hơn không.
em cám ơn cả nhà.
///table
let
Source = Excel.CurrentWorkbook(){[Name="fc"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"thang", Int64.Type}, {"kho", type text}, {"ma", Int64.Type}, {"fc", Int64.Type}, {"nam", Int64.Type}, {"alldaykey", type date}, {"nhapkho", Int64.Type}, {"xuatkho", Int64.Type}, {"falldaykey", type date}, {"code", type text}}),
#"Sorted Rows" = Table.Sort(#"Changed Type",{{"kho", Order.Ascending}, {"ma", Order.Ascending}, {"alldaykey", Order.Ascending}}),
s = Table.AddIndexColumn(#"Sorted Rows", "Index", 0, 1, Int64.Type),
#"Added Custom" = Table.AddColumn(s, "tontam", each [nhapkho]-([fc]+[xuatkho])),
chang = Table.TransformColumnTypes(#"Added Custom",{{"tontam", type number}}),
#"Invoked Custom Function" = Table.AddColumn(chang, "tona", each
( (List.Sum( tonnhap(chang,[kho], [ma], [Index])[nhapkho])-
List.Sum( tonfc(chang,[kho], [ma], [Index])[fc])-
List.Sum( tonnhapxuat(chang,[kho], [ma], [Index])[xuatkho]))+[nhapkho])-([fc]+[xuatkho])
),
#"Changed Type1" = Table.TransformColumnTypes(#"Invoked Custom Function",{{"tona", type number}})
in
#"Changed Type1"
/////ham
fuction
let
j= (tb as table,kho,ma,i)=>
let
f= Table.SelectRows(tb,each [kho]=kho and [ma]=ma and [Index]=i-1)
in
List.Sum(f[fc])
in
j

//
em đang học làm báo cáo power query.
em viết code m để tính số tồn cuối của tháng trước là số dư đầu kỳ của tháng sau theo điều kiện kho=kho, ma=ma, index=index-1
==>kết quả cũng tạm được như ý muốn(em moi hoc nên viết như vậy).
dữ liệu có hơn 5000 dòng như file nó loade dư liệu 20 chưa xong.
Nhờ các AC giúp em có cách nào cho nó tính nhanh hơn không.
em cám ơn cả nhà.
///table
let
Source = Excel.CurrentWorkbook(){[Name="fc"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"thang", Int64.Type}, {"kho", type text}, {"ma", Int64.Type}, {"fc", Int64.Type}, {"nam", Int64.Type}, {"alldaykey", type date}, {"nhapkho", Int64.Type}, {"xuatkho", Int64.Type}, {"falldaykey", type date}, {"code", type text}}),
#"Sorted Rows" = Table.Sort(#"Changed Type",{{"kho", Order.Ascending}, {"ma", Order.Ascending}, {"alldaykey", Order.Ascending}}),
s = Table.AddIndexColumn(#"Sorted Rows", "Index", 0, 1, Int64.Type),
#"Added Custom" = Table.AddColumn(s, "tontam", each [nhapkho]-([fc]+[xuatkho])),
chang = Table.TransformColumnTypes(#"Added Custom",{{"tontam", type number}}),
#"Invoked Custom Function" = Table.AddColumn(chang, "tona", each
( (List.Sum( tonnhap(chang,[kho], [ma], [Index])[nhapkho])-
List.Sum( tonfc(chang,[kho], [ma], [Index])[fc])-
List.Sum( tonnhapxuat(chang,[kho], [ma], [Index])[xuatkho]))+[nhapkho])-([fc]+[xuatkho])
),
#"Changed Type1" = Table.TransformColumnTypes(#"Invoked Custom Function",{{"tona", type number}})
in
#"Changed Type1"
/////ham
fuction
let
j= (tb as table,kho,ma,i)=>
let
f= Table.SelectRows(tb,each [kho]=kho and [ma]=ma and [Index]=i-1)
in
List.Sum(f[fc])
in
j

//