How-to guide
How to Build a Power BI Profit and Loss Statement
A power bi profit and loss statement is a matrix that reads like the P&L your accountant hands you, but refreshes on its own and drills to the account. Getting there takes four pieces: a table that maps every account to a P&L line, measures that compute the subtotals, a deliberate rule for debit and credit signs, and a source feed from QuickBooks or Xero.
Most first attempts drag the chart of accounts onto a matrix, add an amount, and stop there. The result lists accounts, not a statement: there is no Gross Profit row, revenue shows as a negative number, and the grand total adds income and expenses together into a figure nobody can explain. The sections below fix each of those problems in the order we tackle them on finance builds.
How do you map the chart of accounts to P&L lines?
Build a small mapping table that assigns every income-statement account to one P&L line, with a sort order and a sign. Power BI cannot infer that account 4010 is product revenue or that 6200 belongs in operating expenses — you tell it once, in a table, and every measure reads from that table.
We keep the mapping in two related tables. The first is a P&L Layout table with one row per line on the finished statement, including the subtotal lines that no account posts to. The second is the Account dimension, which carries a LineID column pointing at the layout row each account rolls into. The general-ledger fact table relates to Account, and Account relates to P&L Layout, which is the same star schema pattern Microsoft recommends (opens in new tab) with one extra level of hierarchy on the account side.
The layout below is an example. Your account ranges will differ, and that is the point: the ranges live in data, so a new account added in the ledger only needs a row in the mapping, not a change to any measure.
| Order | P&L line | Line type | Example account range | Sign |
|---|---|---|---|---|
| 10 | Revenue | Detail | 4000–4999 | -1 |
| 20 | Cost of Goods Sold | Detail | 5000–5999 | +1 |
| 30 | Gross Profit | Subtotal | None — calculated | — |
| 40 | Operating Expenses | Detail | 6000–7999 | +1 |
| 50 | Operating Income | Subtotal | None — calculated | — |
| 60 | Other Income and Expense | Detail | 8000–8999 | -1 |
| 70 | Net Income | Subtotal | None — calculated | — |
Sort the LineName column by Order so the matrix always shows the statement top to bottom instead of alphabetically. Balance-sheet accounts never get a LineID, which keeps them out of the P&L without a separate filter.
Which DAX measures does a P&L need?
You need one base amount measure, one measure per section, and one measure per subtotal: Revenue, COGS, Gross Profit, Operating Expenses, Operating Income, Other Income and Expense, and Net Income. Subtotals are arithmetic on section measures, never sums of accounts, so they always agree with the lines above them.
Start from the raw ledger, signed the way the ledger stores it:
GL Amount = SUM ( GL[Amount] )
Each section then filters to its line and multiplies by that line’s Sign from the mapping table, so revenue and expenses both display as positive figures:
Revenue = CALCULATE ( [GL Amount] * SELECTEDVALUE ( 'P&L Layout'[Sign] ), 'P&L Layout'[LineName] = "Revenue" )
COGS = CALCULATE ( [GL Amount] * SELECTEDVALUE ( 'P&L Layout'[Sign] ), 'P&L Layout'[LineName] = "Cost of Goods Sold" )
Operating Expenses = CALCULATE ( [GL Amount] * SELECTEDVALUE ( 'P&L Layout'[Sign] ), 'P&L Layout'[LineName] = "Operating Expenses" )
Other Income and Expense = CALCULATE ( [GL Amount] * SELECTEDVALUE ( 'P&L Layout'[Sign] ), 'P&L Layout'[LineName] = "Other Income and Expense" )
The subtotals are plain arithmetic on those measures:
Gross Profit = [Revenue] - [COGS]
Operating Income = [Gross Profit] - [Operating Expenses]
Net Income = [Operating Income] + [Other Income and Expense]
Every one of those uses CALCULATE to change the filter context, and Microsoft’s CALCULATE function reference (opens in new tab) explains exactly how a filter argument replaces an existing filter on the same column. If you separate taxes into their own line, add an Income Tax section measure and subtract it in Net Income; the pattern does not change. The same Revenue and Net Income measures supply the margin and turnover numerators in a Power BI DuPont analysis of return on equity.
How do you keep expense and revenue signs right?
Decide on one display convention and enforce it in the mapping table, not in visuals. The common convention is to show revenue and expenses as positive numbers and let the subtotal measures do the subtracting. A Sign column of -1 on credit-natured lines and +1 on debit-natured lines makes that rule explicit.
The reason this matters is that a transaction-level general ledger stores debits and credits. Revenue is a credit, so in most extracts it arrives as a negative amount; expenses are debits and arrive as positive amounts. Sum them together and you get net income with the sign reversed, which is why so many first-draft P&Ls in Power BI show a loss as a positive number.
Two cautions. First, check what your source actually delivers before applying a sign: a report-level export, such as a Profit and Loss report saved to Excel, has usually already flipped revenue to positive, and flipping it again breaks every subtotal. Second, contra accounts such as sales returns or discounts sit inside revenue but carry a debit balance. Because the sign is applied to the whole line rather than to each account, a contra-revenue debit correctly reduces revenue without any special handling.
Favorability is a separate question from sign. A rise in revenue is good and a rise in expenses is bad, so when you add a prior-year or budget comparison, drive the color rule from a line-type column rather than from the sign of the variance. Our guide to the Power BI budget vs actual report covers that favorable-versus-unfavorable logic in detail, and it reuses the same mapping table you build here.
How do you show subtotal rows in a matrix visual?
Put the P&L Layout line names on the matrix rows and drive the values with a single measure that returns a section total on detail rows and a calculated subtotal on subtotal rows. A SWITCH on the selected line name is the cleanest way to route each row to the right measure.
The trap is that a subtotal row such as Gross Profit has no accounts mapped to it. While the matrix evaluates that row, the layout filter narrows the ledger to nothing, so [Gross Profit] returns blank. Removing the layout filter inside the subtotal branches fixes it:
P&L Value =
VAR _line = SELECTEDVALUE ( 'P&L Layout'[LineName] )
RETURN
SWITCH ( _line,
"Revenue", [Revenue],
"Cost of Goods Sold", [COGS],
"Operating Expenses", [Operating Expenses],
"Other Income and Expense", [Other Income and Expense],
"Gross Profit", CALCULATE ( [Gross Profit], REMOVEFILTERS ( 'P&L Layout' ) ),
"Operating Income", CALCULATE ( [Operating Income], REMOVEFILTERS ( 'P&L Layout' ) ),
"Net Income", CALCULATE ( [Net Income], REMOVEFILTERS ( 'P&L Layout' ) )
)
A few formatting choices turn that matrix into something that reads like a financial statement:
- Turn off row subtotals and the grand total. Net Income is your bottom line; a grand total that adds every row together double-counts the subtotals and means nothing.
- Put the account below the line. Add the account name as a second row level so readers can expand Operating Expenses to the accounts underneath, and leave the statement collapsed by default.
- Make subtotal rows stand out. Use the Line type column to drive bold text or a background on subtotal rows through conditional table formatting (opens in new tab), so Gross Profit and Net Income read as totals.
- Put periods on columns. Month or quarter from the Date table on columns gives a trended P&L; adding a percent-of-revenue measure beside each value gives a common-size view.
How do you feed the statement from QuickBooks or Xero?
Load transaction-level general ledger detail, not a pre-formatted P&L report, whenever the source allows it. Ledger detail carries account, date and amount on every row, which is what the mapping table and the measures need. A pre-built report is fine for a one-off check but is hard to reshape and drill.
The route depends on the accounting system. The table compares the options we see most often for small and mid-sized finance teams.
| Source | How the data reaches Power BI | What to watch |
|---|---|---|
| QuickBooks Online | Excel or CSV exports through Get Data, a third-party ODBC driver or sync tool, or a data warehouse. | Microsoft no longer lists a QuickBooks Online connector, so do not start a new report on it. Exports go stale between runs. |
| QuickBooks Desktop | Report exports, an ODBC driver, or middleware that syncs the company file to a database. | The company file is local, so scheduled refresh needs the sync or ODBC route. |
| Xero | The Xero Accounting API through Power Query, or a small staging database for groups. | There is no first-party Xero connector; tracking categories need mapping alongside accounts. |
Our walkthrough on how to connect QuickBooks to Power BI goes through each QuickBooks route and its trade-offs, and the Xero Power BI dashboard page explains how we pull Xero ledgers through the API. Whichever route you choose, the work you did above carries over unchanged: the mapping table and measures do not care where the ledger rows came from.
What changes when you report several entities?
A single-company P&L needs one mapping table. Several companies usually need one shared reporting chart of accounts, a mapping from each entity’s accounts into it, currency translation, and intercompany eliminations before the totals mean anything. That is a modeling project in its own right rather than an extra slicer.
If you are at that stage, our multi-entity consolidation dashboard service builds the consolidated P&L for you, using the same line-mapping approach scaled up to a group. For a single entity, the steps on this page are the whole job.
Putting it together
A trustworthy P&L in Power BI is a mapping problem first and a visual second. Map every account to a line, apply signs once in that mapping, compute subtotals from section measures rather than from accounts, route the matrix through a SWITCH measure that clears the layout filter on subtotal rows, and load ledger detail from QuickBooks or Xero. Reconcile the first month back to the accounting system’s own P&L report before anyone else sees it; once Net Income ties, every later month inherits the same logic. When the statement ties and you want to know how much revenue covers your costs, our guide to Power BI break even analysis splits the same ledger into fixed and variable costs and computes the break-even point.
Related reading
Keep building your finance reports
Budget vs Actual Report
Variance measures and favorable-versus-unfavorable logic on the same account map.
Connect QuickBooks to Power BI
Exports, ODBC and sync tools, or a warehouse — and when to use each.
Multi-Entity Consolidation
A consolidated P&L across companies, with eliminations and currency handled.
FAQ
Frequently asked questions
Because a transaction-level general ledger extract stores revenue as a credit, and credits usually arrive as negative amounts. Add a Sign column to your line-mapping table, set it to -1 for revenue and other income lines, and multiply by it in the line measure. Report-level exports often present signs already flipped, so check your source first.
Subtotal rows have no accounts mapped to them, so the layout row filters the ledger down to nothing. Calculate those rows with the layout filter removed, for example CALCULATE([Gross Profit], REMOVEFILTERS('P&L Layout')), and return the result through a SWITCH on the selected line name.
Yes. For QuickBooks, use Excel or CSV exports, a third-party ODBC driver or sync tool, or a data warehouse, since Microsoft no longer lists a QuickBooks Online connector. Xero has no first-party connector, so data comes through the Xero Accounting API or a staging database. The mapping and measures stay the same either way.
Usually not at the top level. Put the P&L lines on rows and let readers expand a line to see the accounts beneath it. That keeps the statement short enough to read in a board pack while still letting a controller drill from Operating Expenses down to the single account that moved.
Want a P&L that ties out on the first close?
Bring your chart of accounts to a free demo. Building the line mapping, the subtotal measures and the matrix on your own ledger is exactly the kind of task prepaid Flex hours cover — we scope it, you approve, and most focused builds land in 3–5 business days.
Scope approved before any hours are used · Hours never expire
Tell us the task. We scope it, you approve, and a senior consultant delivers — typically in 3–5 business days. Prepaid hours that never expire.
- Prepaid hours from $100/hour — and they never expire
- Senior-led delivery — 20+ years on the Microsoft platform
- Typical 3–5 business day turnaround
- Full refund if you’re unhappy in your first 4 hours