How to Use Microsoft Power Query for Easy Data Cleanup
Microsoft power query helps you clean data in excel easily. You can use power query’s drag-and-drop tools without knowing how to code. Many people pick microsoft power query because you can quickly change and fix mistakes in your excel data.
The simple interface in power query lets you connect to many data sources. You can clean data without needing help from IT.
You can combine, split, and organize your excel data with easy steps.
Microsoft power query works faster than old ways, so you spend less time cleaning up and more time looking at your data.
You can feel sure using power query to get your excel data ready for any project.
Key Takeaways
Microsoft Power Query helps you clean and sort Excel data fast. You do not need to know how to code.
You can link to many data sources.
You can bring in data easily.
You can look at the data before you use it.
Power Query lets you take out repeats. It helps you fix mistakes. You can filter data and change data types with simple steps.
Using parameters and modular queries makes your work easier.
It also helps you manage your work better. Filtering data early makes things faster. Doing steps in a good order keeps your queries working well.
Microsoft Power Query Setup
Access Power Query
You can start using power query in excel or Power BI. Most users find power query built into excel 2016, excel 2019, and Microsoft 365 for Windows. If you use excel 2010 or 2013, you need a free add-in. Newer versions like excel for Microsoft 365 for Mac offer partial support, but excel 2016 and 2019 for Mac do not support power query. Excel for the web lets you view and refresh queries, but you cannot create or edit them.
Tip: For the best experience, use excel 2016 or newer on Windows. These versions have power query built in, so you do not need extra downloads.
You can access power query from the Data tab in excel. Look for the get data button. This button helps you connect to many sources, such as Text/CSV files, web pages, or other excel worksheets. Power BI Desktop also uses power query. You reach it by choosing get data or by selecting a source directly. Both excel and Power BI let you pick from many data connectors, so you can work with different data sources.
Common ways to access power query in excel:
Go to the Data ribbon and select get data.
Choose a source like Text/CSV, Web, or another excel file.
Launch the Editor
After you connect to a source, you need to open the Power Query Editor. This tool lets you clean and shape your data before you use it in excel or Power BI.
Steps to launch the Power Query Editor in excel:
On the Data tab, open Queries & Connections. Select the Queries tab, right-click your query, and choose Edit.
In a worksheet with query data, select a cell in the results. Go to the Query tab and click Edit.
Open Query Properties from Data > Queries & Connections > Queries tab. Right-click a query, select Properties, go to the Definition tab, and click Edit Query.
Create a new blank query from the Data tab to open the editor.
You can now see your data from different sources. The editor lets you use data connectors to shape and clean your data. You can remove errors, filter rows, and change columns. Power query makes these steps easy, so you can prepare your data for analysis.
Power Query Data Import
Connect to Data Sources
Power query lets you connect to many data sources in excel. There are more than 75 connectors you can use in 2024. You can link to databases, cloud services, files, and websites. This makes it easy to work with all kinds of data for your projects.
You can connect to databases like SQL Server, Oracle, MySQL, PostgreSQL, and Snowflake.
You can use Azure sources such as Azure SQL Database, Azure Synapse Analytics, and Azure Data Lake Storage.
You can pull data from Power Platform sources, including Power BI dataflows and Dataverse.
You can access files like excel tables, CSV, JSON, PDF, and web APIs.
You can connect to SharePoint files, folders, and lists.
You can use cloud services like Salesforce, Microsoft Exchange Online, and Dynamics 365.
Tip: Always check how you log in to each source. Some need a password, some use your work account, and some let you connect without logging in.
Import Data
You can bring data into excel with power query in just a few steps. First, pick your source and follow the steps to add the data to your worksheet. Power query makes this easy and shows you a preview before you load the data.
Go to the Data tab in excel. Click Get Data and pick your source, like From File or From Text/CSV.
Find your file or type in the path for your source.
Open the file. Power query shows a preview so you can see the columns and rows.
Power query finds column names and data types. You see a preview and can use the first row as headers.
Click Edit to open the Power Query Editor. You can change the data, filter rows, or change columns.
Click Close & Load to put the data into excel.
Refresh the query if your source data changes. Power query updates your worksheet with new data.
You get a preview at every step. This helps you find problems early. Some problems are different data sources, missing checks, or messy data. You can fix these by using power query’s cleaning tools and checking the preview before loading. You get better results when you look at your data preview and make changes in the editor.
Data Cleanup Actions
Cleaning your data is very important. You need clean data for any project. Power query gives you easy tools to help. You can remove duplicates, filter rows, fix errors, split columns, merge columns, and change data types. These steps help you get your data ready for analysis in excel or Power BI. Follow these steps to make your data clean and ready to use.
Remove Duplicates
Duplicate rows can mess up your results. Power query helps you find and remove them fast. This way is quicker and safer than deleting rows by hand.
How to remove duplicates in power query:
Change your data into a table in excel. Press
Control + T
to do this.Go to the Data tab. Pick 'From Table/Range' to load your table into power query.
In the Power Query Editor, pick the column or columns to check for duplicates.
On the Home tab, click 'Remove Rows'. Then choose 'Remove Duplicates'.
Click 'Close & Load' to send the clean data back to excel.
Power query removes duplicates for you. You do not need to look for them or use special formatting. When you refresh your query, power query checks for new duplicates and removes them. This saves time and helps you avoid mistakes, even with big or changing datasets.
Filter Data
Filtering helps you see only the rows you want. You can use power query to filter out data you do not need. Filtering early makes your queries faster and easier.
Best practices for filtering in power query:
Use filters right after you load your data. This means you work with less data.
Set the right data types for your columns. This makes filtering better.
Remove columns and rows you do not need. This keeps your data small.
Use parameters if you want to change your filter easily. You do not need to edit the query.
Work with a small sample of your data when building your query. This makes editing faster.
For very big datasets, use DirectQuery mode if you can. This keeps your data in the source and does not load everything.
Do not use complex relationships in your data model. This keeps your queries simple.
Use summary tables if you only need totals.
Filtering early makes your queries run faster. It also helps you see only the data you need for your project.
Fix Errors
Data can have mistakes like extra spaces, blanks, or wrong types. Power query helps you find and fix these problems quickly.
Power query shows errors in the preview pane. You can use 'Keep Errors' or 'Remove Errors' to handle them.
If you see errors from changing data types, you can fix or remove those rows.
You can use the TRIM function to take out extra spaces from text.
Power query can make date and text formats the same.
You can split columns by delimiters to organize messy data.
You can replace errors with default values using conditional columns.
Power query does not change your original data source. It helps you fix errors in your query so your final data is clean and ready for analysis.
Split and Merge Columns
Sometimes your data has too much in one column. Sometimes you need to join columns for better analysis. Power query lets you split and merge columns easily.
How to split a column by delimiter:
Pick the column you want to split in the Power Query Editor.
Go to the Home or Transform tab. Choose 'Split Column' > 'By Delimiter'.
In the dialog, pick your delimiter (comma, semicolon, space, etc.).
Choose where to split: every time, left-most, or right-most delimiter.
Decide if you want to split into columns or rows.
Click OK to split the column.
Rename the new columns to make them clear.
You can also merge columns by picking two or more columns. Then choose 'Merge Columns' from the Transform tab. Pick a separator, like a space or dash, and name the new column.
Splitting and merging columns helps you organize your data. You can handle tricky text data and make your tables easier to use in excel.
Change Data Types
Setting the right data types is important for good analysis. Power query lets you change data types for any column.
How to change data types in power query:
In the Power Query Editor, pick the column you want to change.
Go to the Home or Transform tab. Click the data type icon (like ABC for text or 123 for number).
Choose the right data type (Text, Number, Date, etc.).
Check the preview to make sure your data looks right.
Using the right data types makes things run faster and uses less memory. For example, use integers instead of decimals if you do not need decimal places. Use Date instead of DateTime if you do not need the time.
Do not change data types too often. Too many changes can slow down your queries and cause mistakes.
Always check your data after changing types to make sure nothing broke.
Picking the right data type helps you get good results in excel and Power BI. It also helps stop errors in later steps.
Tip: Use simple steps when you change your data. Apply filters early, set data types before hard changes, and keep each step easy. This makes your queries easier to update and manage.
Power Query Best Practices
Optimize Performance
You can make power query run faster with some easy steps. First, take out columns and rows you do not need. This makes your data smaller and helps reports work better. Query folding lets the data source do hard work for you. If you filter or change data early, query folding helps the source handle it. Pick the right connector for your data type. For big datasets, use incremental refresh with query folding. This only updates new or changed data, so it saves time and memory.
Here are some ways to make things faster:
Take out extra columns and rows to use less memory.
Use summary tables to get results faster.
Set up incremental refresh with query folding to update only new data.
Choose the best data types for each column.
Use DirectQuery for details and import mode for summaries.
Let your database do big calculations before using power query.
Tip: Always filter your data early. This keeps your queries fast and simple.
Use Parameters
Parameters in power query help make your queries flexible. You can set a value once and use it in many places. For example, you can make a parameter to filter by date or region. When you change the parameter, all queries using it update right away. This saves time and keeps your data up to date.
Parameters let you change filters or sources without editing each query.
You can use the same parameter in many queries.
Parameters help you set filter values, which makes query folding better.
Note: Using parameters makes your queries easier to update and use with new data.
Modular Queries
Breaking your power query steps into smaller parts makes things easier. You can make separate queries for loading, cleaning, and changing data. Put these queries into folders like Extract, Transform, and Load. This keeps your project neat and helps you find problems fast.
Name each step clearly and add comments to explain what you do.
Modular queries help you reuse steps and keep your work the same.
Organize queries into groups for better teamwork and clarity.
Grouping and naming your queries well helps keep your power query projects easy to manage.
Troubleshooting Data Issues
Common Problems
You may face some common problems when you work with Power Query. Many users report slow performance and long loading times. Sometimes, your data refresh fails or does not finish. You might see errors like "Expression.Error" or "DataFormat.Error" in your queries. Wide tables, where each question or field is a separate column, can make your data slow and hard to manage. These wide tables also make it tough to keep your data model up to date as your survey or project changes.
Here are some issues you might see:
Slow query performance and slow report loading.
Data refresh schedules that fail or do not run on time.
Errors from using wide tables, which use more memory and slow down your work.
Problems with data governance, such as unclear permissions or trust in your data.
Trouble managing data as your survey or schema changes.
Errors in your data preview, making it hard to get good insights.
You need to spot these problems early. Use the preview pane in Power Query to check your data before you load it. This helps you find issues and get better insights for your data analysis.
Quick Fixes
You can solve many Power Query problems with a few simple steps. Start by reading the error messages in your query. These messages tell you what went wrong. Use the try
expression in Power Query to catch errors in your columns. This lets you see if a value worked or failed. Expand the error record to check the reason and details.
Follow these steps to fix common errors:
Read the error message to find out the type of problem.
Use
try
to catch errors and see which values failed.Expand error details to learn more about the issue.
Add conditional logic to handle or replace error values.
Check your source data and make sure column names and data types are correct.
Set privacy levels to avoid Formula.Firewall errors. 7. Update Power Query to the latest version for better performance.
If you use wide tables, try reshaping your data to a long format by unpivoting columns. This makes your data easier to manage and helps you get faster insights. Always check your data in the preview before you finish. This step helps you catch problems and improve your data analysis.
You can clean your data with microsoft power query in easy steps. First, connect your data to power query. Next, take out any duplicate rows. Then, fix mistakes in your data. Make sure each column has the right data type. If you filter your data early, it works better. Breaking your work into small parts helps you get good results. Many people say power query saves them lots of time. It makes cleaning up data simple. Try using power query on your own files. You will see how fast you can get your reports ready. With more practice, you will get really good at cleaning data. This helps you make better choices.
FAQ
How do you refresh data in Power Query?
You can refresh your data by clicking the Refresh All button on the Data tab in Excel. Power Query will pull in the latest data from your source. This keeps your worksheet up to date.
Can you undo a step in Power Query?
Yes! In the Power Query Editor, you see a list of steps on the right. Click the "X" next to any step to remove it. You can also use Ctrl + Z
to undo your last action.
What file types can you import with Power Query?
You can import many file types, such as Excel files, CSV, JSON, XML, and PDF. Power Query also connects to databases and web data. Check the Get Data menu for all options.
Is Power Query available on Mac?
Power Query works best on Windows. Excel for Microsoft 365 on Mac has limited Power Query features. You can view and refresh queries, but you cannot create or edit them on most Mac versions.