Forum Discussion
Unpivot Columns which are Dynamic
- Anonymous4 years ago
All you need to do is add a Column Count to the list of nested csv files (Add Custom column, = Table.ColumnCount(The name of the folder query--but don't expand the tables yet!). Name the column ColumnCounts. Now sort this table by ColumnCount Descending (critical to get all of your column names when you expand the csv tables)--
Make a new query named MaxColumns=
= List.Max(FolderQuery[ColumnCounts])
Now you can either make a reference or duplicate of your folder query, and then in your Transform File, add the optional Columns parameter, like
= Csv.Document("FileName.csv", MaxColumns)
This will make all of your csv files have the max number of columns. Now you can expand them. You can now also re-sort your combined tables however you need them.
So basically, add the max number of columns to your Csv.Document columns parameter, and sort by most columns to least before expanding the tables.
--Nate
All you need to do is add a Column Count to the list of nested csv files (Add Custom column, = Table.ColumnCount(The name of the folder query--but don't expand the tables yet!). Name the column ColumnCounts. Now sort this table by ColumnCount Descending (critical to get all of your column names when you expand the csv tables)--
Make a new query named MaxColumns=
= List.Max(FolderQuery[ColumnCounts])
Now you can either make a reference or duplicate of your folder query, and then in your Transform File, add the optional Columns parameter, like
= Csv.Document("FileName.csv", MaxColumns)
This will make all of your csv files have the max number of columns. Now you can expand them. You can now also re-sort your combined tables however you need them.
So basically, add the max number of columns to your Csv.Document columns parameter, and sort by most columns to least before expanding the tables.
--Nate