- •Contributors
- •Table of Contents
- •Preface
- •Technical requirements
- •Installing a Power BI gateway
- •Getting ready
- •How it works
- •Authentication to data sources
- •Getting ready
- •How it works
- •Main challenges that Power Query solves
- •Getting ready
- •Technical requirements
- •Getting data and connector navigation
- •Getting ready
- •Creating a query from files
- •Getting ready
- •How it works...
- •Creating a query from a folder
- •Getting ready
- •How it works...
- •Creating a query from a database
- •Getting ready
- •How it works...
- •Creating a query from a website
- •Getting ready
- •How it works...
- •Technical requirements
- •Exploring Power Query Editor
- •Getting ready
- •Managing columns
- •Getting ready
- •Using data profiling tools
- •Getting ready
- •Using Queries pane shortcuts
- •Getting ready
- •Using Query Settings pane shortcuts
- •Getting ready
- •Using Schema view and Diagram view
- •Getting ready
- •Technical requirements
- •Formatting data types
- •Getting ready
- •Using first rows as headers
- •Getting ready
- •Grouping data
- •Getting ready
- •Unpivoting and pivoting columns
- •Getting ready
- •Filling empty rows
- •Getting ready
- •Splitting columns
- •Getting ready
- •Extracting data
- •Getting ready
- •Parsing JSON or XML
- •Getting ready
- •Exploring artificial intelligence insights
- •Getting ready
- •Technical requirements
- •Merging queries
- •Getting ready
- •Joining methods
- •Getting ready
- •Appending queries
- •Getting ready
- •Combining multiple files
- •Getting ready
- •Using the Query Dependencies view
- •Getting ready
- •Technical requirements
- •Setting up parameters
- •Getting ready
- •Filtering with parameters
- •Getting ready
- •Folding queries
- •Getting ready
- •Leveraging incremental refresh and folding
- •Getting ready
- •Disabling query load
- •Getting ready
- •Technical requirements
- •Using M syntax and the Advanced Editor
- •Getting ready
- •Using M and DAX – differences
- •Getting ready
- •Using M on existing queries
- •Getting ready
- •Writing queries with M
- •Getting ready
- •Creating tables in M
- •Getting ready
- •Leveraging M – tips and tricks
- •Getting ready
- •Technical requirements
- •Adding columns from examples
- •Getting ready
- •Adding conditional columns
- •Getting ready
- •Adding custom columns
- •Getting ready
- •Invoking custom functions
- •Getting ready
- •Clustering values
- •Getting ready
- •Technical requirements
- •Using Power BI dataflows
- •Getting ready
- •Centralizing ETL with dataflows
- •Getting ready
- •Building dataflows with Power BI Premium capabilities
- •Getting ready
- •Understanding dataflow best practices
- •Getting ready
- •Technical requirements
- •Exploring diagnostics options
- •Getting ready
- •Managing a diagnostics session
- •Getting ready
- •Designing a report with diagnostics results
- •Getting ready
- •There's more…
- •Using Diagnose as a Power Query step
- •Getting ready
- •Other Books You May Enjoy
- •Index
Combining multiple files 169
Figure 5.27 – Null values for non-matching columns
You can append more than two tables and apply the same logic to a wider number of queries.
Combining multiple files
While working with your data, you may need to automatically combine multiple files. You could use the append transformation method, but if you imagine a use case where there are files loaded into a folder with a defined frequency and you need to see the new data coming at each refresh, it is clear that an alternative method is needed. In this recipe, you will see how to connect and combine multiple files with just a few clicks, regardless of how many there are in the folder.
170 Combining Queries for Efficiency
Getting ready
For this recipe, to test different types of file connectors, you need to download a CSVFiles folder containing CSV files, as shown in the following screenshot:
Figure 5.28 – Local folder with CSV files
In this example, I will refer to the following path: C:\Data\CSVFiles.
How to do it…
Open the Power BI Desktop application to perform the following steps:
1.Go to Get Data, then click on the Folder connector. You can directly enter your folder path or click on Browse and select the folder from the usual browsing section of your machine. Then, click on OK.
2.You will see the following window with a list of files contained in the folder:
Combining multiple files 171
Figure 5.29 – How files from the folder are displayed
3. Click on Transform Data and you will see the following columns:
Figure 5.30 – List of files in Power Query view
172Combining Queries for Efficiency
4.Click on the Combine icon, which you will find in the left corner of the Content column, as shown in the following screenshot:
Figure 5.31 – Combine icon
5.The Combine Files window will pop up. From here, you can define which file to use in the Sample File field and define the File Origin, Delimiter, and Data Type Detection fields. Leave the detected values you see for each field and click on OK, as seen in the following screenshot:
Figure 5.32 – Combine Files window