@Иван Иванов
1. If I understand correctly, the main step of your solution is the "ColumnsToExpand" step
Correct, that's the key step
(If I understood question-1 correctly) Is it possible to make a solution in which the user does not analyze the list of fields, and the program collects all the unique fields from all the files, the program determines the sequence of these fields and outputs the result to the resulting table?
That's exactly what step "ColumnsToExpand" does => the user has nothing to do
To understand how this works you can decompose it as follow and look at the result of each step (ListOfTablesToCombineAtTheEnd, TranformAboveListAsAListOfColumnNames, CombineAboveListOfListsAndRemoveDuplicates) with the APPLIED STEP window:
let
Source = BinariesInFolder,
AddedTableFromWBook = Table.AddColumn(Source, "TableFromSheetOne", each
GetExcelSheetOne([Content]), type table
),
RemovedBinary = Table.SelectColumns(AddedTableFromWBook,
{"name_report", "TableFromSheetOne"}
),
ListOfTablesToCombineAtTheEnd = RemovedBinary[TableFromSheetOne],
TranformAboveListAsAListOfColumnNames = List.Transform(ListOfTablesToCombineAtTheEnd,
Table.ColumnNames
),
CombineAboveListOfListsAndRemoveDuplicates = List.Union(TranformAboveListAsAListOfColumnNames),
ExpandedColumns = Table.ExpandTableColumn(RemovedBinary, "TableFromSheetOne",
CombineAboveListOfListsAndRemoveDuplicates
)
in
ExpandedColumns