Exercise - Load data from various sources into Power BI
The dataset for this course contains sales data from VanArsdel, Ltd. and other competitors. We have seven years of transaction data by day, product, and zip code for each manufacturer. We're going to analyze data from seven countries.
To find the USA sales data, go to Data > USSales > Sales.csv.
To find sales of all other countries, Data > InternationalSales.
Product, Geography, and Manufacturer information is in a Microsoft Excel file called bi_dimensions.xlsx in the USSales subfolder in the Data folder (/Data/USSales/).
Task 1: Get USA sales data
If you don't already have the Power BI Desktop open, launch it now.
Upon opening for the first time, you may see a pop-up presenting Dark mode options. This course will be using the Default mode, but you may choose otherwise. Select Next after making your choice and Close on the next screen.
Sign in using your Power BI credentials.
Select Blank report to open a new Power BI report.
Next, let's set the Locale to US English to make it convenient for the rest of this lab.
From the ribbon, select File, then choose Options and settings. Then, select Options.
Under CURRENT FILE in the left Options pane, select Regional Settings.
From the Locale drop-down, select English (United States).
Then, select OK to close the dialog box.
The next step is to load data into Power BI Desktop.
Note
Power BI Desktop has the capability to connect to 300+ data sources. The newest sources are part of Microsoft Fabric's OneLake catalog. You will not be using OneLake in today's class but to learn more read here: Tutorial: Fabric for Power BI users.
We're using CSV and Excel data files in this lab for simplicity. If you would like a full list of data sources, see: Data sources in Power BI Desktop.
Start by loading USA Sales data, which is in a CSV file.
From the ribbon at the top of the screen, select the Home tab. Then, choose the Get Data drop-down (not the icon).
Select Text/CSV from the Common data sources list.
Browse to the DIAD folder (this folder might be called Attendee if you didn't rename it in Module 1), double-click Data, double-click the USSales folder, and then select the Sales.csv file.
Then, select the Open button.
Note
If your folder appears empty then this likely means you forgot to unzip your class files. Navigate to your location in your file explorer where you saved the class files and unzip the files by right-clicking on the .zip file, then select Extract All.
Power BI detects the data type in each column. There are three options for Data Type Detection: based on the first 200 rows, based on the entire dataset, or not detecting the data type. Since our dataset is large and it takes time and resources to scan the complete dataset, we leave the default option of selecting the dataset based on the first 200 rows.
After completing your selection, you have three options: Load, Transform Data, or Cancel.
Load adds the data from the source into Power BI Desktop for you to start creating reports.
Transform Data allows you to perform data shaping operations such as merging columns, adding extra columns, changing data types of columns, and bringing in other data.
Cancel returns you back to the main canvas.
In the Sales.csv dialog window, select the Transform Data button.
You will be taken to the Query Editor window as shown in the following screenshot. The Query Editor is used to perform data shaping operations. Notice that the sales file you connected shows as a query in the pane to the left of the screen. You can see a preview of the data in the center pane. Power BI predicts the data type of each field (based on the first 200 rows) as indicated by the icons to the left of each column header. In the pane to the right of the screen, steps that the Query Editor performs are recorded in the APPLIED STEPS section.
Notice that Power BI set the Zip column to the data type Whole Number. To make sure that the leading zero isn't dropped from Zip codes that start with zero, we format them as Text.
To do this, select the Zip column.
Then, from the ribbon, select the Transform tab.
From the menu at the top of the screen, select the Data Type drop-down.
Then choose the Text option.
A Change Column Type notification box will open. Select the Replace current button, which overwrites Power BI's predicted data type.
Important
Missing these last two steps will introduce null values when the Zip field contains both characters and numbers.
Now that we covered importing data into Power BI Desktop using Power Query, in the next section, we'll begin the process of loading data from various sources into Power BI.
In the previous unit, you were introduced to importing data into Power BI Desktop using Power Query. Now we begin working with various sources, walking through the steps needed to combine these sources into one model. After you learn how to deal with multiple sources, unit 3 will cover how to clean up all this pulled data.
Task 2: Load various sources
Now, let's get the data that's in the Excel source file called bi-dimensions.xlsx.
From the ribbon at the top of the Power Query Editor, select the Home tab.
Choose the New Source drop-down (not the icon), and then select Excel Workbook.
Browse to the DIAD folder:
Select Data, then the USSales folder
Next, select the bi_dimensions.xlsx file
Then select Open and the Navigator dialog box appears.
The Navigator dialog opens. In the list to the left of the dialog, you see three sheets listed that are in the Excel workbook. It also lists Product_Table, which is a pre-defined Excel table.
Note
Excel Tables are differentiated from worksheets by using different icons.
From the list to the left of the dialog, select the checkbox for geo. In the preview pane, notice that the first few rows are headers and aren't part of the data. We remove them shortly.
Select the checkbox for manufacturer. In the preview pane, notice that the last couple of rows are footers and aren't part of the data. We will remove them shortly.
Select the checkbox for Product_Table. Notice that the different icon indicates this data is stored in an Excel table.
Make sure that Product_Table, geo and manufacturer are selected in the pane to the left, and then select OK.
Notice that three sheets are added as queries in the Query Editor: Product_Table, geo, and manufacturer.
Note
As you click on each query, you will notice some of the queries are not in a format optimized for reporting. You will transform this data in future units within this module.
Task 3: Add other data
In this scenario, the international subsidiaries agree to provide their sales data so that the company's sales can be analyzed together. You created a folder where they each put their data.
To analyze all the data together, you need to import the new data from each of the subsidiaries and combine it with the US Sales you loaded earlier.
When you loaded the US sales data earlier in this unit, you did so with a single file. However, Power BI Gives you the option to load all the files in a folder together at once. This helps save you some time when you load data.
From the Home tab of the Query Editor, select the New Source drop-down (not the icon).
Select More.. from the options list. The Get Data dialog opens.
In the Get Data dialog box, select Folder from the All list.
Then, select the Connect button and the Folder dialog box opens.
In the Folder dialog box, select the Browse.. button.
In the Browse For Folder dialog, navigate to the location where you unzipped the class files.
Open the DIAD folder, then open the Data folder.
Select the InternationalSales folder.
Select OK to close the Browse for Folder dialog box.
Then, select OK to close the Folder dialog box. The selected folder dialog box displays the list of files in the folder.
Note
This approach will load all the files located in the folder. This is useful when you have a group that puts files on an FTP (File Transfer Protocol) site each month and you are not always sure of the names of the files or the number of files. All the files must be of the same file type with columns in the same order.
Select the Combine & Transform Data button at the bottom of the dialog box.
The Combine Files dialog box opens. By default, Power BI again detects the data type based on the first 200 rows. Notice there's an option to select various file delimiters. The file we're working with is comma-delimited, so let's leave the default Delimiter option as Comma.
There's also an option to select each individual file in the folder (using the Sample File drop-down) to validate the format of the files.
Select the OK button located at the bottom of the Combine Files window.
You'll be taken back to the Power Query Editor window with a new query named InternationalSales.
Tip
If you don't see the Queries pane to the left of the screen, select the > (greater than) icon to expand the pane.
Tip
If you don't see the Query Settings pane on the right of the screen, select the View tab in the ribbon and choose Query Settings to view the pane.
Select InternationalSales from the query pane on the left.
Notice that the Zip column is of the Whole Number type. Based on the first 200 rows, Power BI thinks the Zip column consists of whole numbers. But zip codes can be alphanumeric in some regions or contain leading zeros. If we don't change the data type, we receive an error when we load the data. So, let's change the Zip column to data type Text.
Select the Zip column in the InternationalSales query, and then change the Data Type to Text using the drop-down under the Home tab.
The Change Column Type dialog box opens. Select the Replace Current button when prompted.
In the Queries pane, notice that a Transform File from the InternationalSales folder is created. This contains the function used to load each of the files from the folder.
If you compare the InternationalSales and the Sales table, you see the InternationalSales table contains two new columns: Source.Name and Country.
We don't need the Source.Name column in the InternationalSales query. To remove the column from the query:
Select the Source.Name column.
select the Home tab from the ribbon.
Choose the Remove Columns drop-down.
Now, select Remove Columns again.
Note
You may find that Australia is the only country displayed. This is due to the Power Query Editor displaying only the first 1000 rows of any data source. To validate you have the data from all country files you can optionally select the drop-down menu next to the Country column, then select Load more.
You will now see that Australia, Canada, Germany, Japan, Mexico, and Nigeria are all selected.
If you did this optional step, select Cancel.
Now that you loaded all the necessary data for the upcoming report, you're ready to start preparing the data. In the next unit, we'll explore methods to transform and clean our data using Power BI Desktop.



























