Locked lesson.
About this lesson
Importing data from a text file into an Excel table.
Exercise files
Download this lesson’s related exercise files.
Importing Data from Text Files - Begin.xlsx25.2 KB Importing Data from Text Files - Complete.xlsx
44.4 KB Sales - Nov.txt
599 B Sales - Dec.txt
598 B
Quick reference
Importing from Text Files
An overview of importing and cleaning data from a text file using Power Query.
When to use
When you use a text file as a data source for your query and must clean up the (often) messy results so the data can be loaded into Excel.
Instructions
Getting Started
- Create a new query --> From File --> From Text/CSV --> browse for the file to import
- When greeted by the preview window, click Edit
Helpful tips for cleaning up text files
Removing irrelevant rows
- Go to Home --> Remove Rows
- Can be used to remove Top x, Bottom x, or even alternating rows
Tips for removing characters from text
- Leading and trailing whitespace: right-click the column header --> Transform --> Trim
- Internal whitespace: right click the column header --> Replace Values --> replace 2 spaces with 1
- Non-printing characters: right click the column header --> Transform --> Clean
Other tips
- Use Promote First Row to Headers to give the columns decent names
- Rename column headers by double-clicking the header name and typing a replacement
- To change the data type, click on the symbol and choose the data type you want
Filtering
- Use the filter arrows to the right of the column header to remove rows
- Filters can be used to remove values (including nulls) but not errors
Hints & tips
- You can go back through the steps applied to the query in the Query Settings window
- Any query step can be deleted by clicking on the “X” to the left of the query step
Lesson notes are only available for subscribers.