Portfolio / Power Query, step by step
Power Query, step by step
Power Query saves every cleanup step, so you only do the work once. Apply the steps one at a time and see exactly what each one fixes. Then next month’s file arrives, and you just click Refresh.
Press the button to apply each step. I’ll be over here, very impressed.
Meet Tom, who sends a customer report to the owner every month.
The export from the online store is always the same kind of mess: blank rows, extra spaces, names in ALL CAPS, and states written five different ways. Every month he fixes it by hand. Every month it's the same fixes.
Example scenario: the people and businesses on this page are made up.
Before
- The same messy export every month: blank rows, ALL CAPS, five spellings of Ohio
- About 20 minutes of fixing it by hand, every month
- A step forgotten now and then
- Slightly different results depending on who does it
After
- The cleanup recorded once, step by step
- Next month: drop in the file, click Refresh
- The same result every time, whoever clicks
- Those 20 minutes back, every month
Try it yourself
| Row | Customer | City | State | Joined | Spend |
|---|
A simulation of the Power Query Editor in your browser. The formulas shown are real Power Query (M) code.
What this could be worth to you
Twenty minutes every month sounds small. It never stops, though, until you automate it.
Example numbers to start you off. Move the sliders to match your business. These are estimates, not a guarantee or financial advice; your results depend on your situation.
The problem
Monthly exports arrive with the same problems every time, and fixing them by hand wastes time and gives slightly different results each month.
The solution
Power Query, built into Excel and Power BI, records each cleanup step. Point it at next month's file and every step runs again automatically, in the same order, the same way.
How it's built
- LoadConnect to the file or folder the export lands in.
- CleanRemove blanks, trim, fix capitals.
- StandardizeMap every spelling to one value.
- TypeMake dates real dates and money real numbers.
- RefreshNext month, drop in the new file and refresh.
Behind the scenes, the steps are a short Power Query (M) script:
let
Source = Csv.Document(File.Contents("C:\Reports\customers.csv"), [Delimiter=","]),
#"Removed Blank Rows" = Table.SelectRows(Source, each not List.IsEmpty(
List.RemoveMatchingItems(Record.FieldValues(_), {"", null}))),
#"Trimmed Text" = Table.TransformColumns(#"Removed Blank Rows",
{{"Customer", Text.Trim}, {"City", Text.Trim}, {"State", Text.Trim}}),
#"Capitalized Each Word" = Table.TransformColumns(#"Trimmed Text",
{{"Customer", Text.Proper}, {"City", Text.Proper}}),
#"Changed Type" = Table.TransformColumnTypes(#"Capitalized Each Word",
{{"Joined", type date}, {"Spend", Currency.Type}}),
#"Removed Duplicates" = Table.Distinct(#"Changed Type")
in
#"Removed Duplicates"
What it makes possible
- Monthly cleanup turns into one click
- Consistent results, no matter who runs it
- A clean foundation for reports and dashboards
Skills shown
More to try
Never clean the same file twice
I'll set up the cleanup once so it repeats itself. Founding clients get data cleanup from $40 (normally $100).
Starting prices are for smaller projects. Bigger or more complex jobs are priced by scope: how much there is and how long it takes.