Tabellab

You are not signed in — the lab works, but your progress is not saved. Sign up

Lesson 1 of 20 is free. Unlock all 20 hands-on labs, the final exam and your certificate.

Buy course — €9.90
Loading the spreadsheet…

How a bank actually makes money

Most people know that banks lend money at a higher rate than they pay on deposits. Far fewer can turn that sentence into numbers. Yet the gap between what a bank earns on its assets and what it pays on its funding, its net interest income, is the largest single source of profit for most retail and community banks, and the net interest margin (NIM) is one of the first ratios analysts, regulators and investors look at when a bank reports results.

This free lesson is for anyone who needs to read or build those numbers: finance students preparing for exams in banking or financial institutions, junior analysts covering bank stocks, accountants and auditors working with credit unions or community banks, and treasury or ALM (asset-liability management) staff who want to understand the engine they are protecting. In the lab above you work with Lakeside Community Bank, a fictional bank with about $2.7 billion of average assets, and calculate its interest income, interest expense, NII, NIM and spread from its average balance sheet. The bank, its balances and its rates are fictional and chosen for teaching.

The bank balance sheet in plain language

A bank's balance sheet is the mirror image of yours. Your mortgage is the bank's asset, because it is money owed to the bank. Your savings account is the bank's liability, because the bank owes that money back to you. The bank's own equity, the shareholders' money, sits on the liability side too and absorbs losses before depositors are hurt.

  • Earning assets produce interest: loans (mortgages, business loans, consumer loans), investment securities such as government bonds, and reserves held at the central bank where these earn interest.
  • Non-earning assets produce none: buildings, equipment, vault cash that earns nothing, and various receivables. In the lab they are combined in "Other assets" (70).
  • Interest-bearing liabilities cost interest: checking, savings and time deposits, plus wholesale borrowings from other banks or the capital markets.
  • Non-interest-bearing funding costs no interest: other liabilities such as accrued expenses, and equity. Equity is not free in an economic sense, shareholders expect a return, but it does not appear in interest expense.

The lab uses average balances, not year-end balances. Interest accrues every day on whatever balance is outstanding, so a loan book that grew from 1,000 to 1,300 during the year earned interest on roughly 1,150 on average, not on 1,300. Using year-end balances would overstate interest income for a growing bank and understate it for a shrinking one.

The core formulas

For every line, interest = average balance × rate. Add up the asset lines and you have interest income; add up the liability lines and you have interest expense. In Excel, SUMPRODUCT does the multiplication and the adding in one step. The difference is NII = interest income − interest expense.

Two ratios turn that dollar amount into something you can compare across banks of different size and across years:

  • Net interest margin (NIM) = NII ÷ average earning assets. It answers: for every dollar the bank has put to work in interest-earning assets, how much net interest does it keep? Non-earning assets are excluded from the denominator.
  • Net interest spread = yield on earning assets − cost of interest-bearing liabilities. Yield is interest income ÷ earning assets, cost of funds is interest expense ÷ interest-bearing liabilities. The spread compares the average rate earned with the average rate paid.

The two look similar, and they are usually close, but they are not the same. NIM is normally a little higher than the spread because some earning assets are funded by money that costs no interest at all, mainly equity and non-interest-bearing liabilities. That "free funding" earns the full asset yield with no matching expense.

Worked example: Lakeside Community Bank

Worked example: Lakeside Community Bank, FY2026 average balances, USD millions
LineAverage balanceRateInterest (balance × rate)
Assets
Cash & central bank reserves1203.9%4.68
Investment securities4803.6%17.28
Residential mortgages1,1505.4%62.10
Business loans6407.1%45.44
Consumer loans2109.8%20.58
Other assets (non-earning)700.0%0.00
Total assets / interest income2,670150.08
Liabilities & equity
Checking deposits7800.2%1.56
Savings deposits8802.1%18.48
Time deposits (CDs)5203.9%20.28
Wholesale borrowings2104.6%9.66
Other liabilities (non-interest)450.0%0.00
Equity235––
Total / interest expense2,67049.98

Mortgages are the biggest asset (1,150) but, at 5.4%, not the highest yielding; consumer loans earn 9.8% on a much smaller balance, reflecting their higher risk. On the funding side, checking deposits are huge (780) but almost free at 0.2%, while the bank pays 3.9% on time deposits and 4.6% on wholesale borrowings. Put the totals together and the ratios follow:

From balances to NII, NIM and spread
MeasureCalculationResultExcel (lab cells)
Interest incomesum of asset balance × yield150.08=SUMPRODUCT(B3:B8,C3:C8)
Interest expensesum of liability balance × rate49.98=SUMPRODUCT(B11:B15,C11:C15)
Net interest income (NII)150.08 − 49.98100.10=B20-B21
Earning assetsrows 3–72,600=SUM(B3:B7)
Interest-bearing liabilitiesrows 11–142,390=SUM(B11:B14)
Yield on earning assets150.08 ÷ 2,6005.77%=B20/SUM(B3:B7)
Cost of funds49.98 ÷ 2,3902.09%=B21/SUM(B11:B14)
Net interest margin (NIM)100.10 ÷ 2,6003.85%=B22/SUM(B3:B7)
Net interest spread5.77% − 2.09%3.68%=B20/SUM(B3:B7)-B21/SUM(B11:B14)

Lakeside Bank balance sheet (USD m, average)Cash 120Securities 480Mortgages 1,150Business loans 640Consumer 210Other 70Checking 780Savings 880Time deposits 520Wholesale 210Other liab. 45Equity 235Assets 2,670Liabilities & equity 2,670
Figure 1: Lakeside Bank's average balance sheet. Assets equal liabilities plus equity (2,670). Loans dominate the asset side, deposits the funding side.

Interest earned (green) and paid (peach), USD mMortgages62.1Business loans45.4Consumer loans20.6Securities17.3Cash & reserves4.7Time deposits20.3Savings18.5Wholesale9.7Checking1.6
Figure 2: Where the interest comes from and where it goes. Mortgages and business loans earn the most; time and savings deposits cost the most.

Lakeside keeps a NIM of 3.85% and a spread of 3.68%. The difference of about 0.17% is the value of free funding. You can check it: earning assets are 2,600 but interest-bearing liabilities only 2,390, so about 210 of earning assets is funded by equity and other non-interest liabilities (280) after covering the 70 of non-earning assets. Earning the asset yield on that 210 without paying interest on it is worth roughly 210 ÷ 2,600 × 2.09% ≈ 0.17 percentage points of margin, which matches the gap.

Lakeside Bank FY2026: rates in percent0%2%4%6%5.77%Yield2.09%Cost of funds3.68%Spread3.85%NIM
Figure 3: Yield on earning assets (5.77%) minus cost of funds (2.09%) gives the spread (3.68%). NIM (3.85%) is slightly higher thanks to free funding.

How to build it in Excel, step by step

  1. Enter the balance sheet. Labels in column A, average balances in B, yields or rates in C. Give non-earning lines a rate of 0 rather than leaving them blank, so it is clear that the zero is deliberate.
  2. Check that it balances. In B9 type =SUM(B3:B8) and in B17 =SUM(B11:B16) (AutoSum: Alt+=, Mac: Cmd+Shift+T). Both must show 2,670. A bank balance sheet that does not balance means a data-entry error.
  3. Format the rates. Select C3:C15 and press Ctrl+Shift+% (Mac: Cmd+Shift+%), then use Home → Increase Decimal once so 3.9% does not round to 4%.
  4. Interest income. In B20: =SUMPRODUCT(B3:B8,C3:C8). Including the non-earning line with a zero rate is harmless.
  5. Interest expense. In B21: =SUMPRODUCT(B11:B15,C11:C15). Leave equity (row 16) out: it has no interest rate.
  6. NII. B22 already contains =B20-B21.
  7. NIM. In B23: =B22/SUM(B3:B7). Rows 3–7 are the earning assets; row 8 is deliberately excluded.
  8. Spread. In B24: =B20/SUM(B3:B7)-B21/SUM(B11:B14). Rows 11–14 are the interest-bearing liabilities; other liabilities and equity are excluded.
  9. Audit. Click B23 and press Ctrl+[ (Mac: Cmd+[) to jump to the precedent cells, or use Formulas → Trace Precedents to see arrows. Press Ctrl+` to show every formula at once before you hand the file to a reviewer.
For a larger balance sheet, add a column D that tags each line as "Earning" or "Non-earning". Then earning assets become =SUMIFS(B3:B8,D3:D8,"Earning"), and adding a new loan category never breaks your NIM formula.

Bank balance sheet spreadsheet with average balances, yields and net interest margin
The lab above: Lakeside Bank's average balances and rates, and the results block for NII, NIM and spread.

What moves the margin

Once the model is built, you can use it to see what drives NIM. Raise the rate on savings deposits from 2.1% to 2.6%, an increase a bank might need to keep depositors when market rates rise, and interest expense goes up by 880 × 0.5% = 4.4, cutting NIM by about 0.17 points. Shift 100 of balances from securities at 3.6% into consumer loans at 9.8% and interest income rises by 6.2, although in reality the bank would also expect higher credit losses on those loans. A growing share of almost-free checking deposits widens the margin; a shift of depositors into higher-rate time deposits narrows it. This is why bank managements and analysts talk so much about deposit mix and deposit beta, the share of a market rate change that the bank passes on to depositors.

NIM is not the whole profit picture. A bank also earns fee income, pays staff and rent, and sets aside provisions for loan losses. A high NIM earned by lending to risky borrowers can be wiped out by credit losses. That is why the later lessons of this course look at loan pricing and capital alongside the margin.

Reading NIM like an analyst

A single NIM figure means little on its own. Analysts read it in three ways. First, over time: is the margin widening or narrowing from one quarter to the next, and why? A falling NIM while loan balances grow can mean the bank is buying growth with lower loan rates or more expensive deposits. Second, against peers: a bank whose margin is far above similar banks may have a cheaper deposit base, a riskier loan book, or both, and the yield and cost-of-funds lines tell you which. Third, broken into its parts: the table above lets you see whether a change came from the asset side (yields) or the funding side (cost of funds), which is exactly the question management will be asked on an earnings call.

For Lakeside, for example, the business-loan and consumer-loan books together earn 66.0 of the 150.1 of interest income on only 850 of balances, while mortgages earn 62.1 on 1,150. If competition forced mortgage yields down by half a point, interest income would fall by 1,150 × 0.5% = 5.75 and NIM by about 0.22 points. A quick what-if like this, done by changing one cell, is often more useful in a meeting than the base number itself.

Common mistakes and how to spot them

  • Dividing NII by total assets. That gives a different ratio (sometimes reported, but not NIM). If your NIM is a little lower than expected, check whether the 70 of non-earning assets slipped into the denominator: 100.10 ÷ 2,670 = 3.75% instead of 3.85%.
  • Including equity in cost of funds. Equity has no interest rate. If you divide interest expense by all liabilities and equity, the cost of funds looks artificially low.
  • Confusing NIM with spread. They are close but answer different questions. Label both clearly.
  • Using year-end balances. For a bank that grew during the year this overstates interest. Use averages, ideally of daily or monthly balances.
  • Rates typed as whole numbers. Typing 5.4 instead of 5.4% (0.054) makes interest income a hundred times too large. A NIM of several hundred percent is the giveaway.
  • Ranges of different sizes in SUMPRODUCT. =SUMPRODUCT(B3:B8,C3:C7) returns #VALUE!. Both ranges must have the same shape.
  • Rounding inside the calculation. Rounding each line's interest before adding can shift NII. Round only the displayed result.

Quick reference: functions and shortcuts

Quick reference
Function / shortcutWhat it does hereExample
SUMPRODUCTBalance × rate for every line, added up=SUMPRODUCT(B3:B8,C3:C8)
SUMEarning assets, interest-bearing liabilities, totals=SUM(B3:B7)
SUMIFSSum balances by a category column, e.g. "Earning"=SUMIFS(B3:B8,D3:D8,"Earning")
ROUNDRound a ratio for presentation, not in calculations=ROUND(B23,4)
IFERRORAvoid #DIV/0! while the model is incomplete=IFERROR(B22/SUM(B3:B7),0)
Ctrl+Shift+% / Cmd+Shift+%Percent format for rates and marginson C3:C15
Alt+= / Cmd+Shift+TAutoSum the selected columnbelow B3:B8
Ctrl+[ / Cmd+[Jump to the cells a formula refers toon B23
Ctrl+` (grave accent)Show all formulas instead of resultswhole sheet

Real-world uses

  • Reading bank results. Quarterly reports of most banks include an average balance and yield table very similar to the lab. With this model you can recalculate the reported NIM and see what changed.
  • Budgeting at a community bank or credit union. Finance teams project average balances and rates for next year and use the same SUMPRODUCT logic to budget net interest income.
  • Asset-liability management. ALM committees test how the margin reacts if deposit rates rise faster than loan rates, which is the subject of the gap-analysis lesson in this course.
  • Equity research and credit analysis of banks. Analysts compare NIM, yield and cost of funds across banks to judge pricing power and funding quality.
  • Audit and supervision. Auditors use a reasonableness check of interest income (average balance × average yield) to test whether the recorded figure is plausible.

What you will build in the rest of this course

This first lesson is free. The remaining 19 lessons are part of the paid course (a one-time $9.90). Each has its own lab with automatic checking, and together they cover the core numbers of both banking and insurance.

Loan pricing: build the rate from its costs. You build the minimum rate Lakeside must charge on a $2.5 million business loan from funding cost, operating cost, expected loss and a return on capital, and size the gap to the rate the client asks for.

Interest-rate gap analysis & a rate shock. You sort Lakeside's balances into repricing buckets, calculate the one-year cumulative gap and estimate how much net interest income changes if all rates rise by 2 points.

Deposit interest, compounding & APY. You compare compounding frequencies, grow a three-year deposit, check a rival offer and work backwards from an advertised APY to the nominal rate behind it.

Risk-weighted assets & the capital ratio. You weight Lakeside's assets by risk, calculate its capital ratio and work out how much new lending the capital surplus could support.

Insurance premiums: frequency × severity + loadings. The course moves to Ridgeway Mutual, a fictional insurer. You price homeowners cover by segment from expected claims plus expense and profit loadings.

Loss ratio, expense ratio & combined ratio. You turn written premium and claims into earned premium and the three ratios that tell you whether an insurer makes money on its underwriting.

Claims reserving: chain ladder & IBNR. You project general-liability claims to ultimate with the chain-ladder method and estimate the reserve for claims incurred but not yet reported.

Summary

A bank earns interest on its earning assets and pays interest on its deposits and borrowings. Multiply each average balance by its rate with SUMPRODUCT, subtract expense from income to get NII, divide by earning assets for NIM and compare the average rates for the spread. Lakeside Bank earns 150.08 million, pays 49.98 million and keeps 100.10 million, a NIM of 3.85% and a spread of 3.68%. Scroll back up to the lab and build the four formulas yourself, then change a deposit rate and watch the margin move.

Frequently asked questions

What is net interest margin (NIM)?

Net interest margin is net interest income divided by average earning assets. It shows how much a bank keeps, after paying interest on its funding, for every dollar it has invested in interest-earning assets.

How do you calculate net interest margin in Excel?

Calculate interest income and expense with SUMPRODUCT of balances and rates, subtract them to get NII, then divide by earning assets, for example =B22/SUM(B3:B7).

What is the difference between NIM and net interest spread?

Spread is the average yield on earning assets minus the average cost of interest-bearing liabilities. NIM divides NII by earning assets and is usually slightly higher, because part of the assets is funded by equity and other non-interest-bearing funding.

Why are non-earning assets excluded from NIM?

Buildings, equipment and non-interest cash produce no interest, so including them would mix a profitability-of-lending measure with assets that were never meant to earn interest. NII divided by total assets is a different ratio.

Why use average balances instead of year-end balances?

Interest accrues on the balance outstanding during the year. Average balances reflect that, while year-end balances overstate interest for a growing bank and understate it for a shrinking one.

What is a good net interest margin for a bank?

There is no single good value: it depends on the bank's business model, its loan and deposit mix and the interest-rate environment. Compare a bank with similar banks and with its own history rather than with a fixed benchmark.

Keep going: Banking & Insurance Math

This free lab is lesson 1 of 20. Unlock the other 19 hands-on labs, the final exam and your certificate for a one-time €9.90.

  1. Loan pricing: build the rate from its costs
  2. Interest-rate gap analysis & a rate shock
  3. Deposit interest, compounding & APY
  4. Risk-weighted assets & the capital ratio
  5. Insurance premiums: frequency × severity + loadings
  6. Loss ratio, expense ratio & combined ratio
  7. Claims reserving: chain ladder & IBNR
  8. Deposit betas: what a rate rise does to the funding cost
  9. NII bridge: rate and volume effects year over year
  10. Upfront fees, direct costs & the effective loan yield
  11. Branch profitability & the efficiency ratio
  12. Loan-loss allowance: roll-forward, charge-offs & coverage
  13. Client relationship profitability: loan, deposits & fees together
  14. Earned & unearned premium, policy by policy
  15. Actual vs expected claims by region
  16. Deductibles & limits: from ground-up loss to claim paid
  17. Float, investment income & the operating ratio
  18. Storm scenarios: combined ratio and surplus under stress
  19. Final project: eight-quarter dashboard for a bank and an insurer

Buy course — €9.90 See the full course