我從@teylyn in a previous thread得到了一些幫助,以使此代碼正常工作。爲什麼此Power Query操作需要花費很多時間才能完成?
我遇到了一些關於查詢操作時間的麻煩。
任務:
的任務是兩個獨立的聯繫人列表組合成一個完全新的列表。
我還需要刪除共享相同名稱和公司名稱的重複項。
最後,我需要刪除共享相同CompanyID但公司名稱不同的聯繫人。主要列表中的聯繫人應保存以防發生衝突。
下面的代碼工作,但需要很長時間才能完成。
該列表總共包含約8500個聯繫人。
需要2.5秒來遍歷每個聯繫人,將upp添加到大約6小時直到完成。
我的問題:
爲什麼這個操作需要很長時間,是有什麼辦法可以讓它更快?
let
Source = Table.Combine({PrimaryContacts, SecondaryContacts}),
#"Removed duplicates" = Table.Distinct(Source, {"CompanyID", "FirstName", "LastName"}),
#"Sorted rows" = Table.Sort(#"Removed duplicates",{{"CompanyID", Order.Ascending}, {"Email", Order.Descending}}),
#"Filtered rows" = Table.SelectRows(#"Sorted rows", each ["FirstName"] <> null and ["FirstName"] <> ""),
#"Added index" = Table.AddIndexColumn(#"Filtered rows", "Index", 10000, 1),
#"Renamed columns" = Table.RenameColumns(#"Added index",{{"Index", "ContactID"}}),
#"Reordered columns" = Table.ReorderColumns(#"Renamed columns",{"ContactID", "CompanyID", "CompanyName", "FirstName", "LastName}), // I have removed 10 columns for privacy reasons
#"Added index1" = Table.AddIndexColumn(#"Reordered columns", "Index", 0, 1),
#"Filtered rows1" = Table.SelectRows(#"Added index1", each (["ContactID"] = 10000 or ["ContactID"] = 10001 or ["ContactID"] = 10002 or ["ContactID"] = 10003 or ["ContactID"] = 10004 or ["ContactID"] = 10005)),
/* The filter above is temporary to be able to check if next step works */
/* It is the step below that takes too much time to finish */
#"Add custom" = Table.AddColumn(#"Filtered rows1", "Delete", each if ["CompanyID"]= #"Reordered columns"{[Index]-1}["CompanyID"] and ["CompanyName"]<> #"Reordered columns"{[Index]-1}["CompanyName"] then "Delete" else null)
in
#"Add custom"
您的解決方案像一個魅力工作! Thanx @marcel! – MrDark