Data Analyst Full Course for Beginners | Part 8 : Power Query

Hello, everyone! I hope you’re doing great. Today, we’re diving into an exciting and highly useful tool in the world of data analytics: Power Query. By the end of this guide, you’ll not only understand what Power Query is but also learn how to clean, transform, and analyze data using it. And guess what? You’ll get a dataset to practice these skills yourself. Let’s start!

What is Power Query?

Power Query is a powerful tool developed by Microsoft. It comes built into Excel and Power BI but can also be downloaded as an add-on. Power Query allows you to:

  • Import data from various sources such as Excel sheets, CSV files, databases, and even web pages.
  • Transform data without the need to perform repetitive manual steps.
  • Clean and prepare data efficiently for analysis.

Let’s start working with Power Query using a sample dataset.


Steps to Use Power Query

1. Importing Data into Power Query

First, convert your dataset into a table format:

  1. Open your dataset in Excel.
  2. Press Ctrl + T to create a table. Ensure the “Table has headers” option is checked and click OK.

Now, load the table into Power Query:

  1. Go to the Data tab in Excel.
  2. Click on From Table/Range to load the table into Power Query Editor.

Alternatively, if you’re using a CSV or another Excel file:

  • Go to Data > Get Data > From File > From Workbook/CSV, select your file, and click Import.

2. Exploring the Power Query Editor

The Power Query Editor is divided into three main sections:

  1. Ribbon: Contains tabs for data transformation, column operations, and more.
  2. Queries Pane: Shows all the queries (datasets) loaded.
  3. Applied Steps Pane: Tracks every transformation step applied to your data.

3. Cleaning and Transforming Data

Here’s how you can clean and transform your data:

a. Removing Extra Spaces

  1. Select the columns with unnecessary spaces.
  2. Go to Transform > Format > Trim.

b. Capitalizing First Letters

  1. Select the columns (e.g., “Name” and “Department”).
  2. Go to Transform > Format > Capitalize Each Word.

c. Removing Duplicates

  1. Select a column (e.g., “Name”) to check for duplicates.
  2. Go to Home > Reduce Rows > Remove Duplicates.

d. Handling Missing Values

  1. Identify columns with null or missing values.
  2. Select the column, go to Transform > Replace Values, type “null” in the first box, and enter “Not Available” or another placeholder in the second box.

e. Splitting Columns
To split an email into username and domain:

  1. Select the column containing emails.
  2. Go to Transform > Split Column > By Delimiter and choose the delimiter (e.g., @).

f. Changing Data Types

  1. Select numeric or date columns.
  2. Right-click, go to Change Type, and choose the correct type (e.g., Whole Number, Date).
  3. Replace errors using Transform > Replace Errors if Power Query encounters invalid data types.

4. Adding and Merging Columns

Adding Columns

  • Duplicate a column by selecting it, then go to Add Column > Duplicate Column.

Merging Columns

  1. Select two or more columns.
  2. Go to Transform > Text Column > Merge Columns.
  3. Specify a separator (e.g., space or comma) and give the new column a name.

5. Sorting and Filtering Data

  • Use Sort Ascending (A-Z) or Sort Descending (Z-A) from the Home tab to organize your data.
  • Apply filters to specific columns by clicking on the dropdown arrows in the column headers.

Exporting Cleaned Data

Once the data is ready:

  1. Click Close & Load in the Home tab.
  2. The transformed data will load into Excel or Power BI, ready for analysis.

Practice Dataset

To master Power Query, you need hands-on practice. Download a practice dataset and try applying the steps we discussed today.


Conclusion

Power Query is a game-changer for data preparation and cleaning. It simplifies repetitive tasks and makes data analysis more efficient. Use this guide as your go-to resource for Power Query basics.

Let’s transform data and build insights like a pro! 🚀