Forum Discussion
ValeriaBreve
3 years agoPost Partisan
combining Excel files with dfferent columns
Hello! I am trying to combine Excel files in Powerquery that have different columns: The year will always change, and that bit I was able to somehow capture dynamically based on the column position...
- 3 years ago
Hello - yes, this is possible. You would just change the portion of the script that removes columns to only remove those that have duplicates, not to remove the empty columns.
BEFORE
// Combine duplicate plan columns and generic columns into one list. ColumnNamesToRemove = List.Combine ( { DuplicatePlanColumns, GenericColumnNames } ), // -------------------------------------------------------- // Clean up the column names. // -------------------------------------------------------- // Remove specific columns from the source table. RemoveColumns = Table.RemoveColumns ( Source, ColumnNamesToRemove ),AFTER
// Combine duplicate plan columns and generic columns into one list. // ColumnNamesToRemove = List.Combine ( { DuplicatePlanColumns, GenericColumnNames } ), // -------------------------------------------------------- // Clean up the column names. // -------------------------------------------------------- // Remove specific columns from the source table. RemoveColumns = Table.RemoveColumns ( Source, DuplicatePlanColumns),
jennratten
3 years agoSuper User
Hello - yes, this is possible. You would just change the portion of the script that removes columns to only remove those that have duplicates, not to remove the empty columns.
BEFORE
// Combine duplicate plan columns and generic columns into one list.
ColumnNamesToRemove = List.Combine ( { DuplicatePlanColumns, GenericColumnNames } ),
// --------------------------------------------------------
// Clean up the column names.
// --------------------------------------------------------
// Remove specific columns from the source table.
RemoveColumns = Table.RemoveColumns ( Source, ColumnNamesToRemove ),
AFTER
// Combine duplicate plan columns and generic columns into one list.
// ColumnNamesToRemove = List.Combine ( { DuplicatePlanColumns, GenericColumnNames } ),
// --------------------------------------------------------
// Clean up the column names.
// --------------------------------------------------------
// Remove specific columns from the source table.
RemoveColumns = Table.RemoveColumns ( Source, DuplicatePlanColumns),ValeriaBreve
3 years agoPost Partisan
jennratten thanks! I am still testing and testing, I can't just get it to work yet as I want but I see the logic - so it's just a matter of keeping trying from my side 🙂
Thanks! 🙂