当我比较表和转储文本文件时。我将加载powerbi来获取文本文件,然后将其与已创建的表进行比较,以显示匹配的表。这是我用来加载转储并将其与已创建的表进行比较的代码
ActiveWorkbook.Queries.Add Name:="dump", Formula:= _
"let" & Chr(13) & "" & Chr(10) & " Source = Csv.Document(File.Contents(""xx:\location.txt""),[Delimiter=""#(tab)"", Columns=17, Encoding=65001, QuoteStyle=QuoteStyle.None])," & Chr(13) & "" & Chr(10) & " #""Promoted Headers"" = Table.PromoteHeaders(Source, [PromoteAllScalars=true])," & Chr(13) & "" & Chr(10) & " #""Changed Type"" = Table.TransformColumnTypes(#""Promoted Headers"",{{""market"", Int64.Type}, {""category"", Int64.Type}, {""brand"", type text},{""brand status"", type text}, {""vendor_code"", type text}, {""status_last_update_date"", Int64.Type}})," & Chr(13) & "" & Chr(10) & " #""Filtered Rows"" = Table.SelectRows(#""Changed Type"", each ([brand status] <> """" and [brand_status] <> ""Audit"" and [brand status] <> ""SUPPRESSED""))," & Chr(13) & "" & Chr(10) & " " & _
Workbooks("Sheet2").Connections.Add2 "Query - dump", _
"Connection to the 'dump' query in the workbook.", _
"OLEDB;Provider=Microsoft.Mashup.OleDb.1;Data Source=$Workbook$;Location=""us dump"";Extended Properties=""""" _
, "SELECT * FROM [us dump]", 2
ActiveWorkbook.Queries.Add Name:="Table1", Formula:= _