Power Query in Excel 365 is a data transformation and preparation engine that allows you to import data from various sources, clean it, reshape it, and load it into your workbook. It achieves this by recording a sequence of steps—essentially a macro without needing to write code—that can be refreshed instantly whenever your source data changes. To get started, you only need a subscription to Microsoft 365 and a data source, such as a CSV file, a folder of documents, or a database.

What You'll Need

  • A computer running Windows or macOS with an active Microsoft 365 subscription.
  • The Excel desktop application (Power Query functionality is limited in the web version).
  • A data source to connect to (e.g., an Excel workbook, a text/CSV file, a web URL, or a SQL database).
  • Administrative permissions on your computer if you are connecting to secure enterprise databases.

Step-by-Step

  1. Access the Power Query Interface: Open Excel 365 and navigate to the Data tab on the top ribbon. Note that menu labels may differ slightly depending on your version or region. In the Data tab, you will find the "Get & Transform Data" group. This is the gateway to all Power Query functions.
  2. Connect to Your Data Source: Click on the Get Data button. From the dropdown menu, select the source that matches your data. For example, if your data is in another Excel file, select Excel workbook. If you have a folder full of monthly reports that you want to combine into one master list, select From File > From Folder. If you are pulling a table from a website, select From Web.
  3. Select the Specific Table or Sheet: Once you select the file, a Navigator window will appear. This window shows all the tables and worksheets available within that source. Click on the name of the sheet or table you want to import. A preview of the data will appear on the right side of the window.
  4. Enter the Power Query Editor: Instead of clicking Load (which dumps the raw data directly into your sheet), click Transform Data. This opens the Power Query Editor, a separate window where the actual cleaning and shaping happen. This is where you can manipulate the data without affecting the original source file.
  5. Clean the Data: Use the ribbon tools in the Editor to fix common data issues. To remove unnecessary columns, select the columns you don't need and click Remove Columns. To fix headers, if your first row contains the actual column names but Excel hasn't recognized them, click Use First Row as Headers. To filter out blank rows or irrelevant data, click the filter arrow on a column header and uncheck the values you want to exclude.
  6. Transform Data Types: Ensure each column is assigned the correct data type. Click the small icon (e.g., ABC or 123) next to the column header. Change text columns to Text, date columns to Date, and currency columns to Fixed Decimal Number. This is critical because incorrect data types can cause errors during calculations or when loading to a Pivot Table.
  7. Perform Advanced Transformations: If your data is "pivoted" (e.g., months are columns across the top) and you need it in a list format, select the columns and use the Unpivot Columns feature. If you need to combine two columns (like First Name and Last Name), select both, right-click, and choose Merge Columns. You can also create new columns based on logic by using the Add Column > Conditional Column tool.
  8. Review the Applied Steps: Look at the Applied Steps pane on the right side of the editor. Every action you took—filtering, renaming, changing types—is listed here. If you make a mistake, you can click the X next to any step to delete it and revert the data to its previous state. You can also click a step to see what the data looked like at that specific moment in the process.
  9. Load the Data to Excel: Once the data looks exactly how you want it, click Close & Load in the top left corner. You can choose Close & Load to put the data into a new worksheet as a Table, or Close & Load To... to choose whether it should be a Table, a Pivot Table report, or simply a connection (which keeps the data in the background without filling up your spreadsheet).
  10. Refresh the Data: When the source data changes (e.g., you add new rows to the original CSV file), you do not need to repeat these steps. Go to the Data tab in Excel and click Refresh All. Power Query will re-run every single step in your Applied Steps list and update your table instantly.

Common Mistakes

One of the most frequent errors is failing to set the correct data types. If a column is left as "Any" or incorrectly marked as Text when it should be a Number, you will encounter errors when trying to sum those values in a Pivot Table. Always explicitly set your data types before loading.

Another common mistake is renaming the source file or moving it to a different folder after the query has been built. Power Query relies on a hard file path. If the file moves from "C:\Reports\January.csv" to "C:\Archive\January.csv", the query will break because it can no longer find the source. If you must move the file, you will need to update the source path in the Query Settings.

Users also often forget to remove the "Changed Type" step that Excel automatically adds. Sometimes Excel guesses the data type incorrectly at the start; if you try to change it later without deleting the automatic step, you may create conflicting instructions in the Applied Steps list, leading to errors.

Tips

To keep your work organized, rename your queries in the Query Settings pane. Instead of "Table1" or "Query1", use descriptive names like "Sales_Data_2023" or "Client_Contact_List". This becomes essential when you start merging multiple queries together.

Use the "Merge Queries" feature to perform VLOOKUP-style operations. Instead of writing complex formulas in the spreadsheet, you can join two tables based on a common ID column directly within the Power Query Editor. This is significantly faster and more stable for large datasets.

If you are dealing with thousands of rows, consider loading the data as a "Connection Only" and then loading it directly into a Pivot Table (via the Load To... menu). This prevents Excel from becoming sluggish by avoiding the creation of a massive physical table in the worksheet while still allowing you to analyze the data.

Troubleshooting

If you encounter a "Data Format Error" or "Expression Error," the first step is to check the Applied Steps pane. Click through the steps one by one from top to bottom. The step where the error first appears is the source of the problem. This often happens because a column name in the source file was changed, and Power Query is looking for a name that no longer exists.

If the Refresh button does not update your data, check your internet connection (for web sources) or ensure the source file is not open in another program that locks the file. If the file path has changed, go to Data > Get Data > Data Source Settings, select the source, and click Change Source to point it to the new file location.

When the Power Query Editor freezes or becomes unresponsive, it is usually due to a memory bottleneck caused by trying to process too many rows from a slow network drive. Try saving a local copy of the data source on your desktop first to see if the speed improves. If it does, the issue is network latency, not the query itself.

Frequently Asked Questions

Can I use Power Query on a Mac?

Yes, Power Query is available for Excel on Mac, though the interface and some specific connectors may differ from the Windows version. Most core transformation tools are present.

Do I need to know how to code to use Power Query?

No. While Power Query uses a language called "M" in the background, almost every action can be performed using the buttons and menus in the ribbon.

Is there a limit to how much data Power Query can handle?

Power Query can handle millions of rows, far exceeding the 1,048,576 row limit of a standard Excel worksheet. To handle this, load the data as a Connection Only or into the Data Model.

Can I combine multiple files from a folder automatically?

Yes. By using the "From Folder" connector, Power Query can grab every file in a specified directory and stack them on top of each other, provided they have the same column structure.

What happens if the source data structure changes?

If a column is deleted or renamed in the source, the query will likely fail at the step that references that column. You will need to open the editor and update the step to match the new structure.

Can Power Query import data from a PDF?

Yes, in newer versions of Excel 365, you can select Get Data > From File > From PDF to extract tables directly from PDF documents.