QuickBooks Desktop to Excel, with a refresh button
QuickBooks Desktop's Excel button makes a copy that is out of date the next day. Desktop Books gives each company file a Power Query, so the same workbook refreshes from the file whenever you open it.
Three ways to get QuickBooks Desktop into Excel
| Way | What you get | Refresh |
|---|---|---|
| Export to Excel from a QuickBooks report | A copy of one report as it was when you clicked | Export again by hand |
| An ODBC driver on the QuickBooks PC | Tables you can query from Excel on that PC or network | When you refresh, on that PC or network |
| Desktop Books and Power Query | 18 kinds of records and 5 reports, in any workbook, anywhere | When you refresh, or on a schedule in Power BI |
Set it up
- In Desktop Books, open the company file and click New API key. Copy it.
- On the same page, pick what to read (open invoices, customers, A/R aging) and copy the Power Query it shows.
- In Excel: Data > Get Data > From Other Sources > Blank Query, then Advanced Editor, paste and click Done.
- When Excel asks how to connect, choose Basic, paste the key as the user name and leave the password empty.
- Click Close & Load. Next time, Data > Refresh All.
The query for open invoices looks like this:
// Desktop Books: Invoices from "Acme Construction"
// In Excel: Data > Get Data > From Other Sources > Blank Query, then Advanced Editor. Paste this and click Done.
// The first refresh asks how to connect: choose Basic, paste your API key as the User name, leave Password empty.
let
Path = "v1/files/file_8f2c41/invoices",
Options = [flat = "1", limit = "500", status = "open"],
GetPage = (cursor as nullable text) as record =>
let
Query = if cursor = null then Options else Options & [cursor = cursor],
Body = Json.Document(Web.Contents("https://desktop-app.greatwork.company", [RelativePath = Path, Query = Query, ManualStatusHandling = {400, 404, 409, 429, 500, 503}])),
Checked = if Record.FieldOrDefault(Body, "error", null) <> null then error Error.Record("Desktop Books", Record.FieldOrDefault(Record.Field(Body, "error"), "message", "The request didn't work."), Record.FieldOrDefault(Record.Field(Body, "error"), "hint", "")) else if Record.FieldOrDefault(Body, "status", "") = "queued" then error Error.Record("Desktop Books", Record.FieldOrDefault(Body, "message", "This company file answers at the next Web Connector check-in. Refresh again after that.")) else Body
in
Checked,
Pages = List.Generate(() => GetPage(null), each _ <> null, each if _[next_cursor] = null then null else GetPage(_[next_cursor]), each _[data]),
Rows = List.Combine(Pages),
Columns = {"id", "edit_sequence", "created_at", "modified_at", "number", "date", "memo", "currency", "exchange_rate", "customer_id", "customer_name", "due_date", "subtotal", "tax", "total", "applied", "balance", "is_paid", "terms_id", "terms_name", "class_id", "class_name", "status", "days_overdue", "line_count"},
Table = if List.IsEmpty(Rows) then #table(Columns, {}) else Table.FromRecords(Rows, Columns, MissingField.UseNull),
Typed = Table.TransformColumnTypes(Table, {{"id", type text}, {"edit_sequence", type text}, {"created_at", type datetimezone}, {"modified_at", type datetimezone}, {"number", type text}, {"date", type date}, {"memo", type text}, {"currency", type text}, {"exchange_rate", type number}, {"customer_id", type text}, {"customer_name", type text}, {"due_date", type date}, {"subtotal", type number}, {"tax", type number}, {"total", type number}, {"applied", type number}, {"balance", type number}, {"is_paid", type logical}, {"terms_id", type text}, {"terms_name", type text}, {"class_id", type text}, {"class_name", type text}, {"status", type text}, {"days_overdue", Int64.Type}, {"line_count", Int64.Type}}, "en-US")
in
Typed
It reads every page of results and keeps the key out of the workbook, so you can send the file to a client. Why it is written this way.
Reports that stay current
- A/R aging by customer, from the A/R aging report, for the Monday collections call.
- Open invoices with due dates, from invoices with
status=open. - Profit and loss by month, from the profit and loss report with a period for each month.
- Bills due this week, from bills with
status=open.
More about Excel
QuickBooks Desktop for Windows has good Excel tools of its own, and for some people they're all that's needed. Here's where they stop.
What QuickBooks Desktop does on its own
Intuit's help article "Export reports as Excel workbooks in QuickBooks Desktop" covers three things:
- Export any report. Open the report, choose the Excel menu, then Create New Worksheet or Update Existing Worksheet. Updating writes the new numbers into a workbook you exported before.
- Update from inside Excel. In a workbook exported from QuickBooks, the QuickBooks tab in Excel has Update Report, which pulls the latest version of that report. Intuit's article says the company file has to be open when you do it.
- CSV and PDF for the same reports.
That works well when the person building the workbook sits at the QuickBooks PC with the company file open. It doesn't help when:
- the workbook lives on a laptop at home, or on a colleague's computer, with no QuickBooks on it;
- you want one workbook that reads several client files;
- the workbook goes to a client who should be able to refresh it without QuickBooks (give them a key limited to their own file);
- you want the numbers refreshed on a schedule in Power BI without anyone sitting at the QuickBooks PC;
- you want plain records instead of a report layout: one row per invoice or bill, with no report headers or subtotal rows to clean up before you filter or pivot.
That's the gap a Power Query fills: the workbook asks us, and we answer from the last Web Connector check-in.
Building a client workbook
A pattern that works for month-end packages:
- One query per client file for open invoices and one for open bills, each loaded to its own sheet.
- One query per client for the profit and loss for the month just closed. A report for dates you choose runs at the file's next check-in, so the first refresh after you change the month stops with a note to refresh again after that check-in; after that it answers at once. Set the new month the day before the meeting.
- A summary sheet of your own, with formulas that point at those tables. Power Query replaces the rows on each refresh and keeps the table names, so the summary formulas keep working.
- Data > Refresh All before the meeting. Each query reads the file as of its last check-in, which the file's page in your account shows.
Because the key lives in the credential store built into Excel and never in the workbook, you can send the finished file to a client. When they open it, they see the numbers as of your last refresh; they can't refresh it without a key of their own.
Why Basic, with the key as the user name
Excel offers several ways to sign in to a web source. We use Basic because the Power BI service accepts it for scheduled refresh, which Microsoft's Web connector documentation says isn't true of its Web API option, and because Basic keeps the key in Excel's credential store instead of the query text. The Power Query docs go through the query line by line.
When the Export button is the problem
If the Excel button in a QuickBooks report is greyed out or the export fails, that's QuickBooks and Excel talking to each other on that PC, and Intuit's article "Fix export to Excel issues in QuickBooks Desktop" is the place to start. A Power Query doesn't use that export at all, so it isn't affected.
Excel is a trademark of Microsoft Corporation.
14-day trial with one company file. Read-only: nothing is ever written to your books.