- •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
Appending queries 165
Appending queries
Within a single table, you often need to have data coming from different files/tables. You need to append data and have a unique view that will allow you to run more complex analyses. In this recipe, you will see how you can append data in Power Query with just a few clicks.
Getting ready
For this recipe, you need to download the following files:
•FactInternetSales CSV file
•FactResellerSales CSV file
In this example, we will refer to the C:\Data folder.
How to do it…
Once you open your Power BI Desktop application, you are ready to perform the following steps:
1.Click on Get Data and select the Text/CSV connector.
2.Browse to your local folder where you downloaded the two CSV files (FactInternetSales and FactResellerSales) and load them into the Power Query view:
Figure 5.20 – Queries pane
166Combining Queries for Efficiency
3.Select the FactInternetSales query, browse to the Add Column tab, and click on Custom Column:
Figure 5.21 – Custom Column button
4.Create a new column called Channel, add as a formula the value Internet, and click on OK:
Figure 5.22 – Custom Column window
Repeat this step for the FactResellerSales query, with the only difference being on the value to define in the added column. Instead of Internet, enter Reseller:
Appending queries 167
Figure 5.23 – Custom Column window: Reseller
You should end up with an added column for each query, as shown in the following screenshot:
Figure 5.24 – New added columns
168Combining Queries for Efficiency
5.Browse to the Home tab and click on Append Queries as New:
Figure 5.25 – Append Queries as New button
6.Select FactInternetSales in the First table field and FactResellerSales in the Second table field, and click on OK:
Figure 5.26 – Append window
7.You will end up with a query named Append1 (you can rename this as you wish), with appended data from the two queries. In this case, some column headers do not match between the two tables, such as CustomerKey from
FactInternetSales and ResellerKey from FactResellerSales. In this case, the Append1 query will show null values: