Skip to content

Creating an Auditing Tool

A common audit task is to check a list of data received from outside, such as a customer’s payment details, against the business’s own records. Power Query handles this well, because the checks are joins between two tables, and once they are built they can be run again on next month’s files with a refresh.

This page builds a small workbook that does the whole check automatically.

A wholesaler sells on credit to many customers, and each customer receives several invoices a month. At the end of the month the wholesaler sends each customer a statement of the invoices due. The customer pays a batch of invoices with a single payment, and sends a remittance advice that lists the invoices the payment covers.

The task is to check the remittance against the accounts receivable (AR) system and find:

  1. invoices that have not been paid
  2. invoices that have been paid but were not on this month’s statement, such as a late payment of last month’s invoice
  3. invoices paid at a different amount from the amount invoiced

There are two source files. The first is the customer’s remittance:

A worksheet with Invoice Date, Invoice Number and Payment Amount columns, listing invoices numbered SO70593, SO70449 and so on

It lists the invoices the customer has actually paid and the amount paid on each. Its total agrees with the payment received, but not with the statement that was sent.

The second is an extract from the AR system:

A worksheet with Customer Number, Invoice Date, Invoice Number and Payment Amount columns, holding the same invoices with a customer number on each

The two files have much the same layout, and the job is to reconcile the remittance against the AR records.

1. Connect to both files from a new workbook

Section titled “1. Connect to both files from a new workbook”
  • In a new workbook, choose Get Data, then From File, then From Workbook, and pick the remittance file.

The Get Data menu on Excel’s Data tab, open at From File, with From Workbook highlighted

  • In the Navigator, select the sheet and choose Transform Data.

The Navigator showing the remittance workbook with Sheet3 selected and a preview of its invoice dates, numbers and payment amounts

  • The data needs no further work, so just rename the query to Remittance.

The Power Query editor with the query named Remittance, and Applied Steps listing Source, Navigation, Promoted Headers and Changed Type

  • Choose Close & Load To, and then Only Create Connection.

The Import Data dialog with Only Create Connection selected

The query now appears in the Queries & Connections pane as a connection only, which means it holds the data without writing it to a worksheet:

The Queries & Connections pane with one query, Remittance, marked Connection only

  • Do the same for the AR extract, and give that query a clear name too. Both queries are then listed:

The Queries & Connections pane with two connection-only queries, Remittance and AR Listing

  • Grouping the queries makes the workbook easier to follow later. Right-click a query and choose Move To Group, then New Group.

The right-click menu on the Remittance query, open at Move To Group with New Group showing

  • Name the group Connections.

The New Group dialog with the name Connections

  • Move both queries into it, so that the pane looks like this:

The Queries & Connections pane with a Connections group holding Remittance and AR Listing

The next step is to build three report queries:

  1. invoices not paid
  2. invoices paid that were not on the statement
  3. invoices paid with a payment variance
  • On the Data tab, choose Get Data, then Combine Queries, then Merge.

The Get Data menu open at Combine Queries, with Merge highlighted

  • The AR listing is the book of record, so choose it as the first table.
  • Choose Remittance as the second table.
  • Click the Invoice Number column in the first table, and then the Invoice Number column in the second.
  • Leave the join kind as Left Outer, which keeps every AR invoice whether or not it was paid. The dialog reports that 2,160 of the 2,206 AR invoices have a matching payment.

The Merge dialog joining AR Listing to Remittance on Invoice Number with a Left Outer join, where 2160 of 2206 rows match

  • Click the expand button on the new column, untick everything except Payment Amount, untick Use original column name as prefix, and choose OK.

The expand menu on the Remittance column, with only Payment Amount ticked and the prefix option clear

The new column is called Payment Amount.1. Wherever it holds null, no payment in the remittance matched that AR invoice, so the invoice has not been paid.

The merged query, where Payment Amount.1 shows the amount paid on matched invoices and null on unmatched ones

  • Filter Payment Amount.1 to keep only the nulls.

The filter menu on Payment Amount.1 with only (null) ticked

  • The column has done its job, so right-click its header and choose Remove.

The right-click menu on the Payment Amount.1 column header, with Remove highlighted

  • Name the query, then choose Close & Load To, and this time load it to a table on a new worksheet.

The Import Data dialog with Table and New worksheet selected

  • Move the query into a new group called Reports, in the same way as before.

The Queries & Connections pane with the Connections group and a Reports group holding Invoices not paid, with 46 rows loaded

Report 2. Invoices paid but not on the statement

Section titled “Report 2. Invoices paid but not on the statement”
  • Start another merge in the same way, but with the tables the other way round, so that Remittance is first and the AR listing second.

The Merge dialog joining Remittance to AR Listing on Invoice Number with a Left Outer join, where 2160 of 2190 rows match

The rest follows the first report, and the result lists every payment for an invoice that was not on the statement.

One difference may appear when filtering for nulls. The filter list shows only the values Power Query has read so far, and if it says List may be incomplete, null may be missing from it. Choose Load more to read the rest, and then select null as before.

The filter menu on Payment Amount.1 with no (null) entry in the list and a List may be incomplete warning beside a Load more link

  • Finish the query as in the first report: remove the column, name the query, load it to a table, and move it to the Reports group.

Report 3. Invoices paid with a payment variance

Section titled “Report 3. Invoices paid with a payment variance”

The last report finds the invoices that were paid at a different amount from the amount invoiced, whether short or over. It starts from a copy of the first report.

  • Right-click the first report and choose Duplicate.

The right-click menu on the first report in the Reports group, with Duplicate highlighted

  • Rename the copy, and delete its last two steps by clicking the cross beside each in Applied Steps, which leaves Source and Expanded Remittance.

The copy named Payment variance, with Applied Steps reduced to Source and Expanded Remittance

  • On the Add Column tab, choose Custom Column, and subtract the amount paid from the amount invoiced:

The Custom Column dialog with the formula [Payment Amount]-[Payment Amount.1]

  • Filter the new column, unticking 0 and null. The rows that remain are the invoices with a variance.

The filter menu on the Custom column with (null) and 0 unticked and the remaining differences, such as 5 and 2225.96, ticked

  • Rename the columns so that the report reads clearly.

The finished variance report with columns renamed to Expected payment, Actual payment and Difference, listing five short-paid invoices

The tool is complete. To run it on another month’s files, point the two connection queries at the new files and choose Refresh All.

This example follows Matt Allington’s post Power Query as an Audit Tool on Excelerator BI.