In this example, I'm going to combine the files contained within a folder using PowerQuery/M in PowerBI.
Below is the folder and the 4 files contained within the folder.
Each of these files has an identical structure of 2 columns, Column A contains the 'type' (A, B, C or D) and column B contains a 'Value' (between 1 and 100).
In order to combine this data we need to do the following:
- Open PowerBI, click on 'get data' then click on 'More'
- This will open the 'Get Data' window which contains a list of all the connectors available in PowerBI
- Select 'Folder' and then click 'Connect
- This will then present the 'Folder' window, where the folder reference needs to be added. In this instance, the folder name is 'C:\Example\FilesToCombine'
- Click OK, this will then display a window listing the files in the folder and provide some further options
- The options at the bottom of the window provide a few different methods to proceed, in this example we're going to click 'Combine' and then 'Combine & Transform'
- Next you'll see the following window, click on 'Sheet1' and then click 'ok'
- After a couple of seconds, the PowerQuery Editor window will be displayed and a table containing 3 columns will be visible, as shown here
- If there are additional transformations required, then they can be carried out in this window
- To conclude the process, click on the button labelled 'Close & Apply' in the top left part of the ribbon to load the data to the data model
- PowerBI will then provide the progress of the query loading and after a couple of seconds the data will be loaded to the data model.
- To access the data, click on the 'Data' icon on the left side of the screen (highlighted below)
- Then click on one of the columns in the Fields section on the right side of the window (to display the data
- The data will now be displayed in the PowerBI Data view
- If you would prefer to export this data to a new table, one option is to right-click on the table and select 'Copy Table' to copy the table to the clipboard. This can then be pasted into an excel sheet or any other place you wish to use the data
Note - this method can be refreshed within PowerBI and it will import all the files within the folder and combine them into a single table. As long as all of the files in the folder have the same format and structure this query will work fine.
Comments
Post a Comment