Forum Discussion
Power Query: Include all unique columns found in files from folder
- 5 years ago
dataPhix
Can you paste this code and follow the steps to check if it works for you?
Enter your folder pathlet Source = Folder.Files("C:\xx\xx"), #"Removed Other Columns" = Table.SelectColumns(Source,{"Content", "Name"}), #"Added Custom" = Table.AddColumn(#"Removed Other Columns", "Custom", each Table.PromoteHeaders(Csv.Document([Content]))), Custom1 = Table.Combine({#"Added Custom"},{"Name", "Custom"}), #"Sorted Rows" = Table.Sort(Custom1,{{"Name", Order.Descending}}), #"Expanded Custom" = Table.ExpandTableColumn(#"Sorted Rows", "Custom", {"one", "two", "yes", "no", "may be", "three", "four"}, {"one", "two", "yes", "no", "may be", "three", "four"}), #"Reordered Columns" = Table.ReorderColumns(#"Expanded Custom",{"Name", "one", "two", "three", "four", "yes", "no", "may be"}), #"Sorted Rows1" = Table.Sort(#"Reordered Columns",{{"Name", Order.Ascending}}) in #"Sorted Rows1"________________________
If my answer was helpful, please consider Accept it as the solution to help the other members find it
Click on the Thumbs-Up icon if you like this reply 🙂
Hi dataPhix
Just do a Table.Combine of all the tables:
Table.Combine({T1, T2, T3})
Please always show your sample data in text-tabular format in addition to (or instead of) the screen captures. A screen cap doesn't allow people to readily copy the data and run a quick test and thus decreases the likelihood of your question being answered. Just use 'Copy table' in Power BI and paste it here. Or, ideally, share the pbix (beware of confidential data).
Please mark the question solved when done and consider giving kudos if posts are helpful.
Contact me privately for support with any larger-scale BI needs, tutoring, etc.
Cheers