Hello Luis,
is this worse than the Accounts Payable cleanup?
Quite some efforts to achieve the desired result:
Thought that it was a Split Column by Position problem, but it is only for the very first column. But at least there it is very helpful:
let
Source = Table.FromColumns({Lines.FromBinary(File.Contents("C:\yourPath\report to clean.txt"), null, null, 1252)}),
#"Removed Top Rows" = Table.Skip(Source,10),
#"Removed Bottom Rows" = Table.RemoveLastN(#"Removed Top Rows",3),
#"Filtered Rows" = Table.SelectRows(#"Removed Bottom Rows", each ([Column1] <> "" and not Text.Contains([Column1],"------"))),
#"Split Column by Position" = Table.SplitColumn(#"Filtered Rows", "Column1", Splitter.SplitTextByPositions({0, 7}, false), {"Column1.1", "Column1.2"}),
#"Split Column by Position1" = Table.SplitColumn(#"Split Column by Position", "Column1.2", Splitter.SplitTextByPositions({0, 43}, false), {"Column1.2.1", "Column1.2.2"}),
#"Replaced Value" = Table.ReplaceValue(#"Split Column by Position1","1099-Amt. FederalW/H State W/H","$1099-Amt.",Replacer.ReplaceText,{"Column1.2.2"}),
#"Split Column by Delimiter" = Table.SplitColumn(#"Replaced Value", "Column1.2.2", Splitter.SplitTextByDelimiter("$", QuoteStyle.Csv), {"Column1.2.2.1", "Column1.2.2.2"}),
#"Trimmed Text" = Table.TransformColumns(#"Split Column by Delimiter",{{"Column1.1", Text.Trim, type text}, {"Column1.2.1", Text.Trim, type text}, {"Column1.2.2.1", Text.Trim, type text}, {"Column1.2.2.2", Text.Trim, type text}}),
#"Promoted Headers" = Table.PromoteHeaders(#"Trimmed Text", [PromoteAllScalars=true]),
#"Replaced Value1" = Table.ReplaceValue(#"Promoted Headers","",null,Replacer.ReplaceValue,{"Vendor"}),
#"Filled Down" = Table.FillDown(#"Replaced Value1",{"Vendor", "1099-Amt."}),
#"Grouped Rows" = Table.Group(#"Filled Down", {"Vendor", "1099-Amt."}, {{"Name", each [#"Name / Address"]{0}}, {"Address 1", each Text.Combine(List.Skip(List.RemoveLastN([#"Name / Address"],1)), " ")}, {"Address 2", each List.Last([#"Name / Address"])}, {"Federal ID", each [Federal ID Amt.Type]{0}}, {"Status", each [Federal ID Amt.Type]{1}}}),
#"Split Column by Delimiter1" = Table.SplitColumn(#"Grouped Rows", "Address 2", Splitter.SplitTextByEachDelimiter({","}, QuoteStyle.Csv, true), {"Address 2", "Address 3"}),
#"Split Column by Delimiter2" = Table.SplitColumn(#"Split Column by Delimiter1", "Address 3", Splitter.SplitTextByEachDelimiter({" "}, QuoteStyle.Csv, false), {"Address 3", "Address 4"}),
#"Split Column by Delimiter3" = Table.SplitColumn(#"Split Column by Delimiter2", "Federal ID", Splitter.SplitTextByEachDelimiter({" "}, QuoteStyle.Csv, true), {"Federal ID", "Amt.Type"}),
#"Reordered Columns" = Table.ReorderColumns(#"Split Column by Delimiter3",{"Vendor", "Name", "Address 1", "Address 2", "Address 3", "Address 4", "Federal ID", "Amt.Type", "Status", "1099-Amt."}),
#"Trimmed Text1" = Table.TransformColumns(#"Reordered Columns",{{"Vendor", Text.Trim, type text}, {"Name", Text.Trim, type text}, {"Address 1", Text.Trim, type text}, {"Address 2", Text.Trim, type text}, {"Address 3", Text.Trim, type text}, {"Address 4", Text.Trim, type text}, {"Federal ID", Text.Trim, type text}, {"Amt.Type", Text.Trim, type text}, {"Status", Text.Trim, type text}, {"1099-Amt.", Text.Trim, type text}}),
#"Changed Type with Locale" = Table.TransformColumnTypes(#"Trimmed Text1", {{"1099-Amt.", Currency.Type}}, "en-US")
in
#"Changed Type with Locale"
Regards,
Matthias