Power Query

Clean a messy bank export with Power Query

9 min read

Turn a sloppy monthly bank export into a tidy table once, then refresh it every month with one click.

The problem

Every month the bank sends the same kind of file, and every month someone spends an hour fixing it. Dates arrive as text. Amounts are text with dollar signs. Debits and credits sit in separate columns. Three junk rows sit above the headers, and a "Total" row sits at the bottom where it will quietly double your sum.

Cleaning that by hand works, but it is slow, and it is different every time. One month you forget to delete the footer row. The next month you paste over a formula. Nobody can tell what was done to the numbers.

Power Query fixes this by recording each cleanup step in order. You do the work once on a sample export. From then on, you drop in the new file and click Refresh. The steps replay in the same order every time, and you can read them back to see exactly what happened to the data.

The idea in four boxes

You do the cleanup once, in the Power Query editor. Excel stores each step. After that, a new export goes through the same steps every time.

The exportBank file in a folder
→
Clean onceSteps are recorded in order
→
Load a tableOne tidy table on its own sheet
→
RefreshSteps replay with one click

The one requirement is consistency. The bank must send the same columns with the same headings each month. If it changes the layout, the query will tell you with an error rather than quietly producing wrong numbers.

Before and after

Here is a typical export, exactly as the bank sends it. Notice the report title and blank row above the headers, the text amounts with dollar signs, the split debit and credit columns, and the total at the bottom. Step through the cleanup to see what each stage does to the data.

Step through the cleanup

Pick a stage. Cells that changed in that step are highlighted.

The finished table has real dates, real numbers, one signed Amount column (debits negative, credits positive), tidy descriptions, and no junk rows. That is the shape a PivotTable, a reconciliation or a SUMIFS wants.

One caveat: banks differ on how they show negatives. This one uses separate Debit and Credit columns, so the sign comes from which column the amount sits in. If yours puts parentheses or minus signs inside a single Amount column, skip the sign step and just convert the text to numbers.

Set it up in eight steps

You need Excel 2016 or later, or Microsoft 365. Menu names below are for Windows desktop Excel. They are close on Mac but not identical.

  1. Save the export where it will stay. Put it in a dedicated folder, such as Bank Exports, and keep the file name predictable. Each month you will replace the file or point the query at the new one.
  2. Load it into the Power Query editor. Go to Data > Get Data > From File > From Text/CSV, pick the file, then click Transform Data. Do not click Load yet. If your bank sends .xlsx, use From Workbook instead.
  3. Remove the junk rows. On Home, use Remove Rows > Remove Top Rows and enter the number of rows above your headers (3 in the sample). Then choose Use First Row as Headers. Next, filter the first column to exclude "Total" so the footer row disappears without depending on its position.
  4. Set the data types. Change Posted to Date. Change Debit, Credit and Balance to Currency. Setting types early makes bad values show up as errors you can see, instead of text that sums to zero.
  5. Replace blanks with zero. Select Debit and Credit, then Transform > Replace Values and swap null for 0. Without this, the next step returns null whenever either side is empty.
  6. Combine debits and credits into one Amount. Go to Add Column > Custom Column, name it Amount, and enter [Credit] - [Debit]. Credits come out positive and debits negative. Then remove the Debit and Credit columns and drag Amount so it sits before Balance.
  7. Tidy the descriptions. Select Description and use Transform > Format > Trim, then Format > Clean. Bank text often has double spaces inside, which Trim does not touch, so also use Replace Values to swap two spaces for one. Run it twice for triple spaces. Rename Posted to Date while you are here.
  8. Load the result. Click Home > Close & Load To, choose Table, and pick a new sheet. Rename the query BankExport in the right-hand pane so you can find it later.

Tie it out before you trust it

The sum of Amount should equal total credits minus total debits from the bank's own Total row. In the sample that is 12,800.00 minus 5,233.40, or 7,566.60. If the numbers match, the cleanup did not lose or double anything.

Where it breaks

The query is only as stable as the file the bank sends. These are the failures that show up most, and what to do about each.

What you seeLikely causeFix
Column 'Debit' not found after refreshThe bank renamed or reordered a headerOpen the query and fix the step that names the column. Check the export header first.
Dates are wrong or show errorsLocale mismatch, such as day-first dates read as month-firstIn the type step, use Change Type > Using Locale and pick the matching region.
Amount sum is off by a totalThe Total row was not filtered outConfirm the filter in step 3 is still in the Applied Steps list.
Everything is null in AmountBlanks were not replaced with zeroRe-check step 5 ran before the Custom Column.
Top rows differ from last monthThe bank added or removed a title rowChange the number in Remove Top Rows, or filter on the header text instead.
New month appends nothingThe file path points at last month's fileReplace the file in place, or change the source path under Applied Steps.

If the layout changes often, point the query at a folder instead of a single file. See Combine monthly files automatically for that setup.

Your monthly routine

Once the query exists, the monthly job takes about a minute:

  1. Save the new export over last month's file, or into the folder.
  2. Open the workbook and go to Data > Refresh All.
  3. Run the tie-out check against the bank's totals.

The cleanup steps live inside the workbook, so anyone on the team can open the query, read the Applied Steps list and see what was done to the data. That audit trail is usually the part finance teams value most.

Need this built for your team?

If your export has quirks this guide does not cover, such as multiple accounts in one file, merged cells or memo lines on a second row, we can build it for you. Start with a free 30 minute strategy session.

Book a free strategy session