Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Power Query Practice Exercises for Real Skill

· 7 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Power Query practice exercises should always follow one repeatable loop: connect to a small messy table, clean it with a handful of named steps, load the result, then break it deliberately and fix it. That loop, repeated with different data shapes, is what builds real fluency. To start you need a spreadsheet application with Power Query built in (Excel or Power BI Desktop) and a folder of messy sample files you can save copies of. Nothing else is required, and no prior M knowledge helps at the beginner stage.

What You'll Need

  • A desktop install of Excel (Microsoft 365, Excel 2021 or later on Windows or Mac) or Power BI Desktop. Power Query is not in Excel for the web or in the mobile apps, so every exercise below runs on desktop only.
  • A working folder on your computer for the sample files, plus a second empty folder for loading outputs.
  • A shorthand lookup table you type yourself, such as a two-column list of region codes and region names, so you can practise merging.
  • Optional but useful: a source CSV or two exported from a real system (order exports, survey downloads, inventory lists) with deliberate problems such as merged header cells, trailing spaces and mixed date formats.

Step-by-Step

  1. Build your sample data first. In a new workbook, type a table with at least six columns: Order ID, Date, Region Code, Customer, Quantity and Unit Price. Enter about twenty rows. Then add the problems on purpose: put a title row above the headers, leave some Region Codes blank, type one date as text, add extra spaces after a couple of customer names, and duplicate two Order IDs. Save the file and keep a pristine copy, because every exercise below needs a fresh one.
  2. Import the messy table. In Excel, select any cell inside the table and use Data > From Table/Range. In Power BI Desktop, use Home > Get data > Excel workbook, then select the table. Labels vary slightly by version and platform, so look for the Data or Home ribbon tab whichever app you are in. A preview window opens showing how Power Query read the data.
  3. Practise promoting headers. Because your title row sits above the real headers, the first row of data is being treated as column names. Use Home > Use First Row as Headers, then check that every column name now matches what you typed. Rename any column that still looks wrong by double-clicking its header.
  4. Fix data types deliberately. Select the Date column and use Home > Data Type to set it to Date. Watch for cells that fail to convert: Power Query shows errors in place. Do not delete the errors yet; right-click the column and use Replace Errors once you understand what caused them. Set Quantity to Whole Number and Unit Price to Decimal Number.
  5. Clean text. Right-click the Customer column and choose Transform > Trim, then Transform > Clean. Compare the before and after in the preview so you can see exactly what each transformation did. This habit of checking the preview after every step is the single most important exercise of all.
  6. Remove duplicates and blanks. Select the Order ID column, right-click and choose Remove Duplicates. Then filter the Region Code column to remove nulls. Note how each action adds a named step in the Applied Steps pane on the right. Click an earlier step to see the table as it looked then, then click back to the end.
  7. Add a calculated column. Use Add Column > Custom Column and enter a formula such as [Quantity] * [Unit Price]. Name it Line Total. Power Query formulas are case-sensitive and reference columns in square brackets, so type the names exactly as they appear in the headers.
  8. Practise merging. Load or type your region lookup table, then use Home > Merge Queries with the order table, matching Region Code to the lookup code. Choose the join kind, expand the lookup's Region Name column, and confirm that the row count has not changed unexpectedly.
  9. Practise grouping. Use Home > Group By on Region Name, adding a sum of Line Total. This produces a summary table. Then undo it by deleting the step, so you can see how steps are reversible.
  10. Load the result. Use Home > Close & Load to send the cleaned table to a new worksheet or to the data model. Reopen the query afterwards with Data > Queries & Connections > right-click > Edit to prove the connection persists.
  11. Repeat with a wildcard exercise. Create another sample file with dates in three different formats and practise using the Date tools under Transform to standardise them. This is the most realistic problem you will meet in real exports.
  12. Break it on purpose. Rename a source column in the original table, then refresh the query. Read the error message carefully, find the step that fails, and repair it. Doing this five times teaches you more than five clean runs.

Common Mistakes

The biggest mistake is cleaning data by hand in the worksheet and then importing it. Power Query steps are only useful if they run every time you refresh, so every correction must live inside the query, not in cells. The second is skipping data types at the end of the process; set types as early as the data allows, because later steps such as merging and date arithmetic fail silently or wrongly when text is present in a numeric column. Third, people rename steps to meaningless labels, then cannot find the broken one months later; rename each step as you go. Fourth, merging without checking row counts, which quietly duplicates records when the lookup table has repeat values. Finally, deleting error rows instead of investigating them hides real data problems that will reappear on the next refresh.

Tips

Work in a copy of every workbook so a failed exercise costs nothing. Keep exercises small: ten to thirty rows is enough to spot mistakes and fast enough to refresh repeatedly. Use the Applied Steps pane as documentation, and insert a blank query through Home > New Source > Blank Query to experiment with formulas in isolation. When an exercise works, save it as a template including the sample data, so you can rerun it in a few months. Time yourself on repeats: a merge and group exercise that takes twenty minutes the first time should take three the second time.

Troubleshooting

If the preview shows a single column of junk, you probably imported a text file with the wrong delimiter; reopen the source settings and set the correct separator. If a column will not convert to Date, apply the query at a locale matching the source, because day-first and month-first dates read differently in different regions. If refresh fails with an error about a missing column, a step name no longer matches the source; open the failing step and update the column reference. If load fails because the output range overlaps existing data, choose a new worksheet or clear the target area. If the query is very slow with large data, remove unused columns early rather than at the end. When something is badly broken, delete steps from the bottom of the Applied Steps list backwards until the preview looks correct, then rebuild forwards.

Frequently Asked Questions

Can I practise Power Query in Excel for the web?

No. Power Query authoring runs in the desktop versions of Excel and in Power BI Desktop. The web app offers limited data tools but not the full query editor.

Do I need to know M language to start?

No. Most exercises are done through the ribbon, which writes M for you. Reading the generated formula in the formula bar is a good way to learn it gradually.

Which exercises should I do first?

Header promotion, data types, trimming text, removing duplicates and merging a lookup. These cover the majority of real cleanup work.

Why does my query keep failing after the source file changes?

Steps refer to exact column names. If a name or sheet changes in the source, update the affected step rather than recreating the query.

Can I use my own work data for practice?

Use copies and remove or mask personal information. Follow your organisation's data rules, since query files cache a snapshot of the source.