Locked lesson.
About this lesson
One of the most important data sources to pull from is a database, but they have their own interesting nuances as well. In this lesson we will take a look at those.
Exercise files
Download this lesson’s related exercise files. You can download source data files for the course from the resources section of your Lessons page.
Getting data from Databases.xlsx19.6 KB Getting data from Databases - Completed.xlsx
18.7 MB
Quick reference
Getting Data from Databases
An overview of importing data from a database into Power Query.
When to use
When your data to be used in the query exists in a separate database system.
Instructions
Getting started
- Create a new query --> From Database --> choose the appropriate database
- Browse to or enter the location of the database
- If required, enter your database security credentials
The preview window
- Use the preview window to browse the tables and views
- Selecting the Multiple Items checkbox will allow you to import multiple tables at once
- Once done selecting tables, click Edit
Best practices for working with Database data
- Make your tables “Short and Narrow”
- Remove any columns that are not needed for your analysis
- Filter out any rows unneeded for analysis
- Rename columns to friendly names
- Ensure that the final step is to force the data type for each column
Working with green keywords
- Columns could contain the following green keywords
- Record or Value: These indicate a multi-column, single row data point based on the database’s internal relationships and can be expanded into the extra columns
- Table: These indicate a multi-column, multi row data table based on the database’s internal relationships and can be expanded into the extra columns
- Clicking
- The green text of a keyword will drill down into that record or table
- The white space next to the keyword will display the contents in the preview window at the bottom of the screen
- Clicking on the left-right arrows on the top right corner of the column header will expand the related records into new columns and/or rows
Hints & tips
- When expanding the values nested in a Value or Tables:
- You can check which columns you would like to expand
- Checking the option to Use Original Column Name As Prefix will prepend the new columns with the name of the column being expanded
Lesson notes are only available for subscribers.