토. 8월 16th, 2025

Have you ever spent hours manually cleaning and reshaping data in Excel? 😫 Copy-pasting, deleting rows, splitting columns – it’s a tedious and error-prone process. What if I told you there’s a built-in Excel tool that can automate all these tasks, making your data preparation a breeze? ✨ Say hello to Power Query!

In this comprehensive guide, we’ll dive into the basics of Power Query, covering how to import data from various sources and perform essential transformations. Get ready to supercharge your Excel skills! 🚀


🤔 What is Power Query?

Power Query, also known as Get & Transform Data, is an Excel add-in (and now a built-in feature in recent versions) that allows you to:

  • Connect to a wide variety of data sources (Excel files, CSVs, databases, web, etc.).
  • Transform the data (clean, reshape, merge, append).
  • Load the transformed data into Excel, a data model, or other destinations.

The best part? Once you’ve set up your transformations, they can be refreshed with a single click whenever your source data changes. No more manual repetition! 💪


🚀 Getting Started: Accessing Power Query

Power Query is easily accessible from the Excel ribbon.

  1. Go to the Data tab.
  2. Look for the “Get & Transform Data” group.

    You’ll see options like “Get Data,” “From Table/Range,” “Recent Sources,” and “Show Queries.”


📥 Importing Data: Your First Step

Let’s explore how to bring data into Power Query from common sources.

1. From an Excel Table/Range 📊

This is super common if your data is already in Excel.

  • Scenario: You have data in a sheet, and you want to clean it.
  • Steps:
    1. Select any cell within your data range.
    2. Go to Data > From Table/Range.
    3. If your data is not already in an Excel Table, Excel will ask you to confirm the range and if your table has headers. Check “My table has headers” if applicable. Click OK.
    4. The Power Query Editor window will open with your data loaded! 🎉

2. From a Text/CSV File 📄

CSV (Comma Separated Values) files are widely used for data exchange.

  • Scenario: You received a sales_data.csv file that needs to be imported and cleaned.
  • Steps:
    1. Go to Data > Get Data > From File > From Text/CSV.
    2. Browse and select your CSV file, then click Import.
    3. A preview window will appear, showing Excel’s attempt to detect the delimiter and data types. This is usually accurate.
    4. Click “Transform Data” to open the Power Query Editor. (Avoid “Load” if you need to clean it first!)

3. From a Folder (Multiple Files) 📁

This is incredibly powerful for combining multiple similar files (e.g., monthly sales reports).

  • Scenario: You have 12 CSV files, one for each month’s sales, in a folder, and you want to combine them into one dataset.
  • Steps:
    1. Place all your files (e.g., Jan_Sales.csv, Feb_Sales.csv, etc.) into a single folder.
    2. Go to Data > Get Data > From File > From Folder.
    3. Browse and select the folder, then click Open.
    4. A window will show a list of files in that folder. Click “Combine & Transform Data” (or “Combine & Load” if you don’t need transformations).
    5. Power Query will show a sample file and ask you to confirm parameters (like delimiter for CSV). Click OK.
    6. The Power Query Editor will open, showing a combined table from all files! This is magic! 🪄

4. From the Web 🌐 (Brief Mention)

Yes, you can even pull data directly from web pages (if the data is in a structured table format).

  • Scenario: You want to import a table of statistics from a Wikipedia page.
  • Steps:
    1. Go to Data > Get Data > From Other Sources > From Web.
    2. Paste the URL of the web page.
    3. Power Query will try to detect tables on the page. Select the table you need and click “Transform Data.”

🛠️ The Power Query Editor Interface

Once you’ve imported data, you’ll be in the Power Query Editor. It looks a bit like Excel, but with specialized tools for transformation.

  • Ribbon: Contains various transformation options (Home, Transform, Add Column, View).
  • Queries Pane (Left): Lists all your queries. You can have multiple queries in one workbook.
  • Data Preview (Center): Shows a preview of your data.
  • Query Settings Pane (Right):
    • Properties: Name your query here (e.g., CleanedSalesData).
    • Applied Steps: This is crucial! Every transformation you apply is recorded here as a step. You can review, reorder, modify, or even delete steps. This is what makes Power Query so powerful and auditable. 🕵️‍♀️

🧹 Basic Transformations: Cleaning Your Data

Now, let’s get our hands dirty and clean some data! These are some of the most common transformations you’ll use.

1. Removing Columns ❌

  • Why: You often import data with many columns you don’t need.
  • How: Select the column(s) you want to remove > Right-click > Remove Columns. Or, go to Home tab > Remove Columns.

2. Renaming Columns ✍️

  • Why: Column names might be cryptic or contain special characters.
  • How: Double-click on the column header and type the new name, then press Enter. Alternatively, right-click on the column header > Rename.

3. Changing Data Types 🔢📅 ABC

  • Why: Crucial for accurate calculations and filtering. Power Query tries to detect types, but it’s not always perfect.
  • How: Click the icon (e.g., ABC, 123, calendar) next to the column header > Select the correct data type (e.g., Whole Number, Decimal Number, Date, Text).

    • Example: If your “Sales” column is Text type, you can’t sum it! Change it to Decimal Number.

4. Filtering Rows 🔍

  • Why: To focus on a subset of your data (e.g., sales from a specific region).
  • How: Click the filter arrow next to the column header (just like in Excel) > Uncheck unwanted values or use “Text Filters,” “Number Filters,” or “Date Filters” for more advanced conditions.

    • Example: Filter “Region” column to only show “East” and “West”.

5. Sorting Data ⬆️⬇️

  • Why: To arrange your data in ascending or descending order.
  • How: Click the filter arrow next to the column header > Select “Sort Ascending” or “Sort Descending.”

6. Removing Duplicates 🗑️

  • Why: To ensure uniqueness (e.g., a list of unique customer IDs).
  • How: Select the column(s) you want to check for duplicates > Right-click > Remove Duplicates.

    • Example: Select “CustomerID” column and remove duplicates to get a unique list of customers.

7. Splitting Columns ✂️

  • Why: To separate combined data into individual columns.
  • How:
    • By Delimiter: Select the column > Home tab > Split Column > By Delimiter. Choose your delimiter (e.g., comma, space, custom) and how to split (left-most, right-most, each occurrence).
      • Example: Split “Full Name” (e.g., “John Doe”) into “First Name” and “Last Name” using “Space” as the delimiter.
    • By Number of Characters: Select the column > Home tab > Split Column > By Number of Characters. Specify the number of characters.
      • Example: Split “ProductID” (e.g., “ABC12345”) into “Product Category” (“ABC”) and “Product Code” (“12345”) by splitting at 3 characters.

8. Merging Columns 🔗

  • Why: To combine data from multiple columns into one.
  • How: Select the columns you want to merge (in order) > Right-click > Merge Columns. Choose a separator (or none) and a new column name.
    • Example: Merge “First Name” and “Last Name” into a “Full Name” column using a “Space” as a separator.

9. Adding Custom Columns ➕

  • Why: To create new columns based on existing ones using formulas (M language).
  • How: Go to Add Column tab > Custom Column.
    • Enter a new column name.
    • Enter your formula. Power Query uses a language called M. It’s case-sensitive!
      • Example 1 (Simple Math): Calculate “Total Price” by multiplying “Quantity” and “Unit Price”. [Quantity] * [Unit Price]
      • Example 2 (Conditional Logic): Categorize “Order Status” based on “OrderAmount”. if [OrderAmount] > 1000 then "Large" else "Small"
      • Example 3 (Text Manipulation): Combine text strings. [Product Name] & " - " & [SKU]

10. Unpivoting Columns 🔄 (A Game Changer!)

  • Why: This is one of the most powerful transformations! It transforms data from a “wide” format (where categories are columns) to a “tall” format (where categories are rows). This is crucial for analysis in Excel or other tools.
  • How:
    • Scenario: You have sales data where each month is a column (e.g., Product | Jan | Feb | Mar). You want Product | Month | Sales.
    • Steps:
      1. Select the columns you don’t want to unpivot (i.e., your identifier columns, like “Product”).
      2. Right-click on the selected columns > Unpivot Other Columns.
      3. Alternatively, select the columns you do want to unpivot (i.e., “Jan”, “Feb”, “Mar”) > Right-click > Unpivot Columns.
        • The result will be two new columns: “Attribute” (which will be your months like “Jan”, “Feb”) and “Value” (which will be the sales figures). You can then rename these.

💾 Loading Data Back to Excel

Once you’re satisfied with your transformations, it’s time to load the cleaned data back into Excel!

  1. In the Power Query Editor, go to Home tab.
  2. Click “Close & Load” or “Close & Load To…”.
    • Close & Load: Loads the data into a new sheet in your current workbook as an Excel Table. (Most common choice).
    • Close & Load To…: Gives you options to load as a Table, only create connection (if you want to load to a Data Model for Power Pivot), or directly to a Data Model.

Your cleaned data will appear in a new sheet, ready for analysis, charting, or further use! 🎉


🔄 Refreshing Data

The magic of Power Query is its refreshability. If your source data changes, you don’t have to repeat all those steps!

  1. Go to the Excel sheet where your query results are loaded.
  2. Go to Data tab > Refresh All (to refresh all queries) or select the query table and click Refresh (to refresh just that one).
  3. Power Query will re-run all the applied steps from your source data, and your table will update! ✨

🌟 Benefits and Conclusion

Power Query is an indispensable tool for anyone working with data in Excel. By mastering these basics, you’ll be able to:

  • Save Time: Automate repetitive data cleaning tasks. ⏰
  • Reduce Errors: Minimize manual mistakes. ✅
  • Improve Data Quality: Ensure your data is clean and consistent. 🧼
  • Boost Productivity: Spend more time analyzing and less time preparing. 📈

This is just the tip of the iceberg! Power Query can do much more, including merging queries, appending queries, invoking custom functions, and connecting to databases. But with these foundational skills, you’re well on your way to becoming a Power Query pro!

What are your favorite Power Query transformations? Share them in the comments below! 👇 G

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다