Refresh a query to clean next month's data
Power Query basics7 minPremium
Builds on Clean columns as steps in Power Query.
Last month a payroll analyst in Raleigh built a query that cleans the timesheet export, and it took her an afternoon. This month's export arrived this morning, and the cleanup should take her a minute.
How it works
A query keeps two things: where its data comes from, and the list of steps. Refresh reads the source again, runs every step on what it finds and replaces the loaded table with the result.
- Data > Refresh All refreshes every query in the workbook, and on Windows CtrlAltF5 does the same. To refresh one query, right-click its loaded table and choose Refresh.
- When the source is a table on a sheet, add the new rows to the table, then refresh.
- When the source is a file, save the new file over the old one, with the same name in the same folder, or point the query at it: Data > Get Data > Data Source Settings, select the old file, click Change Source, browse to the new one, close the dialog and refresh.
Example
February's rows added to the analyst's source table, and the loaded table after Data > Refresh All:
Common mistakes
- Fixing a value in the loaded table. The next refresh brings the old value back. Fix it in the source, or add a step.
- A filter that ticks this month's values. New values next month are left out. Filter with a rule, such as Greater Than Or Equal To or Does Not Begin With.
- A renamed column in the new file. The step that names it stops with an error such as "The column 'Hours' of the table wasn't found". Rename the column back in the file, or change the step to the new name.
- Refreshing before the new data is in place. The query reads last month's data again. Add the rows or change the source first.
In short
- Refresh reads the source again and runs every step, then replaces the loaded table.
- Add new rows to the source table, or point the query at the new file with Change Source, then refresh.
- Steps written as rules keep working next month, and typing in the loaded table doesn't survive.
Practice
Premium3 exercises: 1 quiz question, 1 set of steps and 1 query.
Practice is part of Premium
Every lesson is free to read, and you can practice the free lessons without an account. This lesson's exercises are part of Premium, which you add to a free account.
Have one? Sign in