<!-- https://learnsql.cpetoday.com/analyze/data-modeling-for-finance -->
# Data modeling for finance

A data model is the set of tables you load into Power BI or Power Pivot and the relationships between them. A good model makes most measures one line long. A bad model gives totals that look right and are not. This guide covers the finance decisions behind a model: what one row means, how budgets and dates fit, how a chart of accounts becomes a statement, and the mistakes that double a total.

The DAX side of these ideas is in [DAX for financial reporting](/analyze/dax-financial-reporting), and the shape of each sample database is in [Data structures and Power BI limits](/analyze/data-structures). Each query below runs on the sample database named in its block. The numbers were checked against that data before they were published.

## Facts and dimensions in the general ledger

A **fact** table holds the measurements: one row per event, with the amounts. A **dimension** table holds the descriptions you filter and group by: the account, the fund, the date, the cost center. Together they form a star: a fact in the middle, dimensions around it, and one relationship per dimension.

In the general ledger the fact is the journal line. Each line holds a date, an account, the fund and cost center it was charged to, and an amount in a debit or a credit column. The dimensions are the chart of accounts, the funds, the cost centers and the calendar.

> Diagram: A star schema: a General Ledger lines fact table in the middle, joined one-to-many from four dimension tables: Date, Account, Department and Vendor.

The `nonprofit` sample is already in this shape. Its journal line table carries `fund_id` and `cost_center_id` as well as `gl_account_id`, so the fund and the account both come from a dimension. The next query uses that. It totals FY2026 expense by net asset class, which is the restriction group of the fund: with or without donor restrictions. Runs on `nonprofit`.

```sql
SELECT f.net_asset_class,
       SUM(l.debit - l.credit) AS expense_net
FROM gl_journal_lines AS l
JOIN gl_journal_entries AS e ON e.journal_entry_id = l.journal_entry_id
JOIN gl_accounts AS a        ON a.gl_account_id = l.gl_account_id
JOIN funds AS f              ON f.fund_id = l.fund_id
WHERE e.fiscal_year = 2026
  AND a.account_type = 'Expense'
GROUP BY f.net_asset_class
ORDER BY expense_net DESC;
```

**What it returns.** Expenses without donor restrictions are 5,085,990.02 and expenses with donor restrictions are 2,228,961.07. The measure is one formula, debit minus credit, on the fact. The grouping comes from the dimension. That split is the design: the fact stays small and the descriptions stay in one place.

## Grain: decide what one row means

The **grain** is what one row of a table represents. Write it in one sentence before you build anything: "One row is one journal line," or "One row is one budget amount for one fiscal year and account." If you cannot write that sentence, the table is not ready. Tables with different grains do not belong in one table, and comparing two grains needs care.

These are the grains in the sample databases you will meet in this guide:

| Table | One row is | Database |
|---|---|---|
| `gl_journal_lines` | one debit or credit on one account, fund and cost center, from one entry | `nonprofit`, `cpafirm` |
| `budgets` | one budget amount for one fiscal year, account, fund and cost center | `nonprofit` |
| `fact_budget` | one budget amount for one fiscal month, category and region | `retailwh` |
| `fact_sales` | one line on a customer order | `retailwh` |
| `fact_inventory_snapshot` | one product at one store at one month-end | `retailwh` |

> Diagram: Three levels of grain. One journal line holds the most detail. Summing by month gives one row per month and account. Summing by fiscal year gives the grain of an annual budget.

The rule is simple. Bring both to the same grain first, then compare them. The next section shows what goes wrong without that step.

> **Watch out.** A fact at a coarse grain, such as a yearly budget, cannot be joined to a fine one, such as a journal line, without multiplying the coarse amount.

## Budget against actual: align the grain first

The question: **which expense accounts are over budget?** The budget is one row per account per fiscal year. The journal has thousands of lines for the same account in the same year. A direct join makes one budget row match every line, so the budget is counted once per line.

The query below is the mistake. It joins the budget straight to the journal lines and sums the budget. Runs on `nonprofit`.

```sql
SELECT SUM(b.budget_amount) AS expense_budget_after_join
FROM budgets AS b
JOIN gl_accounts AS a        ON a.gl_account_id = b.gl_account_id
JOIN gl_journal_lines AS l   ON l.gl_account_id = b.gl_account_id
JOIN gl_journal_entries AS e ON e.journal_entry_id = l.journal_entry_id
                             AND e.fiscal_year = b.fiscal_year
WHERE b.fiscal_year = 2026
  AND a.account_type = 'Expense';
```

**What it returns.** 3,722,082,400. The budget for all expense accounts in FY2026 is 7,334,200. The join multiplied every budget amount by the number of journal lines behind it. No error appears, and a report built on this number would look large and plausible, which is what makes the mistake dangerous.

The fix is to aggregate each side to the common grain, which is fiscal year and account, and then join the two results. Runs on `nonprofit`.

```sql
WITH budget AS (
    SELECT gl_account_id, SUM(budget_amount) AS budget
    FROM budgets
    WHERE fiscal_year = 2026
    GROUP BY gl_account_id
), actual AS (
    SELECT l.gl_account_id, SUM(l.debit - l.credit) AS actual
    FROM gl_journal_lines AS l
    JOIN gl_journal_entries AS e ON e.journal_entry_id = l.journal_entry_id
    WHERE e.fiscal_year = 2026
    GROUP BY l.gl_account_id
)
SELECT a.account_number, a.account_name, b.budget,
       ISNULL(x.actual, 0) AS actual,
       ISNULL(x.actual, 0) - b.budget AS over_under
FROM budget AS b
JOIN gl_accounts AS a ON a.gl_account_id = b.gl_account_id
LEFT JOIN actual AS x ON x.gl_account_id = b.gl_account_id
WHERE a.account_type = 'Expense'
ORDER BY over_under DESC;
```

**What it returns.** Nineteen expense accounts. For an expense, a positive `over_under` means the account spent more than budget. The four over budget in FY2026 are:

| Account | Budget | Actual | Over (+) |
|---|---|---|---|
| 6210 Food Purchases | 468,200.00 | 508,833.91 | +40,633.91 |
| 6600 In-Kind Goods Distributed | 383,400.00 | 417,400.00 | +34,000.00 |
| 6900 Pledge Write-offs | 28,900.00 | 30,345.00 | +1,445.00 |
| 6520 Technology & Software | 179,200.00 | 180,015.14 | +815.14 |

Every other expense account came in under budget. Food purchases is the one to ask about first, because it is the largest overrun. Across all expense accounts, actual spending is 7,314,951.09 against a budget of 7,334,200, so the year as a whole came in under plan, and the overruns sit in a few accounts.

> Diagram: Top, a wrong join: one budget row is joined to every journal line of its account, so the budget is counted once per line. Bottom, the right way: sum the budget and the actual to account and year, then compare the two single rows. Food Purchases is 40,633.91 over budget.

The same discipline applies when the grains are monthly. `retailwh` has a budget by fiscal month, category and region, and actual sales at the order line. Align both to month, category and region, then add up by category. Runs on `retailwh`.

```sql
WITH act AS (
    SELECT d.fiscal_year, d.fiscal_period, sub.category_key, s.region_key,
           SUM(f.net_amount_usd) AS actual
    FROM fact_sales AS f
    JOIN dim_date AS d        ON d.date_key = f.order_date_key
    JOIN dim_product AS p     ON p.product_key = f.product_key
    JOIN dim_subcategory AS sub ON sub.subcategory_key = p.subcategory_key
    JOIN dim_store AS s       ON s.store_key = f.store_key
    WHERE d.fiscal_year = 2026
    GROUP BY d.fiscal_year, d.fiscal_period, sub.category_key, s.region_key
), bud AS (
    SELECT fiscal_year, fiscal_period, category_key, region_key, SUM(budget_usd) AS budget
    FROM fact_budget
    WHERE fiscal_year = 2026
    GROUP BY fiscal_year, fiscal_period, category_key, region_key
)
SELECT c.category_name,
       SUM(b.budget) AS budget,
       SUM(a.actual) AS actual,
       SUM(a.actual) - SUM(b.budget) AS variance
FROM bud AS b
LEFT JOIN act AS a
       ON a.fiscal_year = b.fiscal_year
      AND a.fiscal_period = b.fiscal_period
      AND a.category_key = b.category_key
      AND a.region_key = b.region_key
JOIN dim_category AS c ON c.category_key = b.category_key
GROUP BY c.category_name
ORDER BY variance DESC;
```

**What it returns.** Outdoor is 78,477.93 over budget (1,853,524.30 against 1,775,046.37), Apparel is 44,079.26 over, Beauty is 7,802.11 over, Home is 31,279.41 under and Electronics is 211,045.05 under. The total of the actual column, 9,120,656.88, equals the FY2026 total of `fact_sales`. That check matters. A budget cell with no sales stays in the list because of the `LEFT JOIN`. A sale with no budget cell would drop out of the answer, and the total would be short.

## Dates: one calendar, many roles

A **date table** has one row for every day, with no gaps, and every fiscal attribute you need. Every fact joins to it. A gap in the calendar breaks time-intelligence measures such as year to date. This check counts the rows in the `cpafirm` fiscal calendar against the number of days in its range. Runs on `cpafirm`.

```sql
SELECT COUNT(*) AS calendar_rows,
       DATEDIFF(day, MIN(calendar_date), MAX(calendar_date)) + 1 AS days_in_range
FROM fiscal_calendar;
```

**What it returns.** 2,556 rows and 2,556 days. No day is missing and none is repeated.

**Name the fiscal year before you publish.** The sample databases do not all start the year in January. In `cpafirm` and `nonprofit`, fiscal 2026 runs from July 2025 to June 2026, and it is named for the year it ends. In `retailwh` the year starts in April. Check it on one date. Runs on `retailwh`.

```sql
SELECT calendar_date, fiscal_year, fiscal_period_name
FROM dim_date
WHERE calendar_date IN ('2025-03-31', '2025-04-01');
```

**What it returns.** 31 March 2025 is FY2025-P12, the last period of fiscal 2025. 1 April 2025 is FY2026-P01. The first day of a fiscal year is a common place for a report to slip a month, so confirm it against a known date.

**Role-playing dates.** One invoice has three dates: issue, due and payment. Each one can answer a different question, and the model needs a date table for each role, or one date table with several relationships that are switched on as needed. This query puts the issue date and the due date of the same invoice into fiscal periods. Runs on `cpafirm`.

```sql
SELECT TOP 3 i.invoice_number, i.issue_date, i.due_date,
       fi.fiscal_period_name AS issued_in,
       fd.fiscal_period_name AS due_in
FROM invoices AS i
JOIN fiscal_calendar AS fi ON fi.calendar_date = i.issue_date
JOIN fiscal_calendar AS fd ON fd.calendar_date = i.due_date
WHERE fi.fiscal_period <> fd.fiscal_period
ORDER BY i.issue_date DESC;
```

**What it returns.** INV-2026-03848, issued 22 October 2026 and due 21 November 2026, is issued in FY2027-P04 and due in FY2027-P05. Billings are counted in the month issued, and receivables are aged from the due date.

> **Watch out.** A report that uses the wrong date for each question will disagree with the aging.

> Diagram: One invoice with three dates. Its issue date is the active relationship to one shared date table and lands in FY2027 period 4. Its due date lands in period 5 through an inactive relationship. Its payment date is blank because the invoice is not yet paid.

Power BI handles this with one active relationship and the other relationships inactive. A measure activates an inactive one with `USERELATIONSHIP`. You can read the payment side of the same idea in the next query, which measures how far after the due date each payment arrived. Runs on `cpafirm`.

```sql
SELECT p.payment_method,
       COUNT(*) AS applications,
       ROUND(AVG(CAST(DATEDIFF(day, i.due_date, p.payment_date) AS float)), 1)
         AS avg_days_after_due,
       SUM(CASE WHEN p.payment_date > i.due_date THEN 1 ELSE 0 END) AS paid_late
FROM payment_applications AS pa
JOIN payments AS p ON p.payment_id = pa.payment_id
JOIN invoices AS i ON i.invoice_id = pa.invoice_id
WHERE p.fiscal_year = 2026
GROUP BY p.payment_method
ORDER BY applications DESC;
```

**What it returns.** ACH averages 8.1 days after the due date across 2,000 applications, and 1,304 of them were late. Checks average 8.7 days, credit cards 8.3. Trust applications show payment dates about 30 days before the due date. That is a pattern to ask about, not a finding to report.

The same role idea works for a process. In `retailwh`, one order has an order date, a ship date and a delivery date, each a separate key into the date table. The next query joins the calendar three times, once per role. Runs on `retailwh`.

```sql
SELECT COUNT(*) AS delivered_orders,
       ROUND(AVG(CAST(DATEDIFF(day, o.calendar_date, s.calendar_date) AS float)), 1)
         AS days_order_to_ship,
       ROUND(AVG(CAST(DATEDIFF(day, s.calendar_date, d.calendar_date) AS float)), 1)
         AS days_ship_to_delivery
FROM fact_order_pipeline AS f
JOIN dim_date AS o ON o.date_key = f.order_date_key
JOIN dim_date AS s ON s.date_key = f.shipped_date_key
JOIN dim_date AS d ON d.date_key = f.delivered_date_key
WHERE f.status = 'Delivered';
```

**What it returns.** 50,044 delivered orders, on average 2.0 days from order to ship and 4.3 days from ship to delivery. Each alias is one role of the same date table.

> Exercise: For fiscal 2026, show the number of invoices and the billed total (rounded to cents) for each fiscal period. Use the fiscal calendar on the invoice issue date. Period order.


## Chart of accounts: the hierarchy that becomes the statements

A chart of accounts is a hierarchy. Accounts roll up to parents, and the parents become the lines of the financial statements. In `cpafirm`, `gl_accounts` has a `parent_account_id`. Revenue account 4100 Tax Preparation Revenue rolls up to 4000 Professional Fee Revenue, and 5010 Salaries & Wages rolls up to 5000 Personnel Costs.

> Diagram: Chart of accounts tree. Professional Fee Revenue (4000) is a parent with no postings and seven revenue accounts beneath it that carry postings. Personnel Costs (5000) is a parent with no postings and two expense accounts beneath it.

Two rules keep the hierarchy honest:

1. **Post to leaves only.** A parent is a heading. If you total a parent together with its children, the children are counted twice, once in themselves and once in the parent. The next query checks that no line posts to a parent. Runs on `cpafirm`.

```sql
SELECT COUNT(*) AS postings_to_parent_accounts
FROM gl_journal_lines AS l
WHERE l.gl_account_id IN (SELECT parent_account_id
                          FROM gl_accounts
                          WHERE parent_account_id IS NOT NULL);
```

**What it returns.** 0. The parent accounts carry no postings, so a total built from the leaves cannot double count.

2. **Use one sign convention for each statement.** The ledger stores debits and credits. A statement shows revenue as a positive number, and expenses as positive too. Revenue is credit minus debit, because revenue is normally a credit balance. Expense is debit minus credit. Assets are debit minus credit, and liabilities and equity are credit minus debit.

This query builds an income statement for FY2026. It maps each leaf to its parent name and applies the sign convention. Runs on `cpafirm`.

```sql
SELECT COALESCE(p.account_name, a.account_name) AS statement_line,
       a.account_type,
       SUM(CASE WHEN a.account_type = 'Revenue' THEN l.credit - l.debit
                ELSE l.debit - l.credit END) AS amount_shown_positive
FROM gl_journal_lines AS l
JOIN gl_journal_entries AS e ON e.journal_entry_id = l.journal_entry_id
JOIN gl_accounts AS a        ON a.gl_account_id = l.gl_account_id
LEFT JOIN gl_accounts AS p   ON p.gl_account_id = a.parent_account_id
WHERE e.fiscal_year = 2026
  AND a.account_type IN ('Revenue', 'Expense')
GROUP BY COALESCE(p.account_name, a.account_name), a.account_type
ORDER BY a.account_type DESC, amount_shown_positive DESC;
```

**What it returns.** Professional Fee Revenue of 3,890,467.73, Personnel Costs of 2,177,596.99 and Operating Expenses of 322,160.68. The revenue line is 29,209.77 lower than the invoice total for the year, 3,919,677.50. That gap is account 4900, Billing Adjustments and Discounts, which carries a debit balance of 29,209.77. Every statement total should be explainable by its accounts, and this one is.

> Exercise: How many accounts are in each account type? Show the type and the count, in alphabetical order by type.


## Balances are not additive across time

Some numbers are **semi-additive**. You can add them across products, stores or accounts, but never across dates. A cash balance is the clearest example. The balance on 31 March plus the balance on 30 April is not a number anyone needs. The balance at the end of the period is the number.

The query below reads the operating cash balance (account 1000) at four month-ends. Runs on `cpafirm`.

```sql
WITH month_ends AS (
    SELECT CAST(d AS date) AS month_end
    FROM (VALUES ('2026-03-31'), ('2026-04-30'), ('2026-05-31'), ('2026-06-30')) AS v(d)
)
SELECT m.month_end,
       (SELECT SUM(l.debit - l.credit)
        FROM gl_journal_lines AS l
        JOIN gl_journal_entries AS e ON e.journal_entry_id = l.journal_entry_id
        JOIN gl_accounts AS a        ON a.gl_account_id = l.gl_account_id
        WHERE a.account_number = 1000
          AND e.entry_date <= m.month_end) AS cash_balance
FROM month_ends AS m
ORDER BY m.month_end;
```

**What it returns.** 3,144,909.35 at 31 March, 3,412,550.19 at 30 April, 3,649,159.30 at 31 May and 3,695,503.29 at 30 June. The change over the quarter is the last balance minus the first, 550,593.94. Adding the four balances gives a figure of about 13.9 million, which is meaningless. The same test on inventory shows the risk more clearly. The next query adds the on-hand units of six month-ends in `retailwh`. Runs on `retailwh`.

```sql
SELECT SUM(i.on_hand_units) AS on_hand_added_across_six_month_ends
FROM fact_inventory_snapshot AS i
JOIN dim_date AS d ON d.date_key = i.month_end_date_key
WHERE d.calendar_date BETWEEN '2025-10-01' AND '2026-03-31';
```

**What it returns.** 156,731 units. Each month-end is a count of much of the same stock, so adding the six counts counts the same units six times. The on-hand count at 31 March 2026 is the balance to report, and it is 23,662 units.

In Power BI, the measure for a balance is the last value in the period, such as `LASTNONBLANK` or `CLOSINGBALANCEMONTH`. For an average balance, use an average over the periods. Never use a plain `SUM` over a date column for a balance.

## Many-to-many: the bridge that multiplies totals

A **many-to-many** relationship is one where a row on each side can match many rows on the other. A CPA engagement has a preparer, a manager and a partner, and each of them is on many engagements. The database stores this with a **bridge table**, one row per engagement and person. The bridge is necessary, and it is also the most common source of double-counted totals.

> Diagram: One sale of product 2 meets the bridge table, which holds two rows for product 2, one for tag 1 and one for tag 3. The join therefore produces two rows for the single sale, and its amount is counted twice.

In `cpafirm`, `engagement_staff` is the bridge. Every engagement has a manager, a partner and at least one preparer, so the table holds about 3.25 rows per engagement. The next query sums the fee for FY2026 two ways. Runs on `cpafirm`.

```sql
SELECT (SELECT SUM(e.fee_amount)
        FROM engagements AS e
        WHERE e.fiscal_year = 2026) AS fees_correct,
       (SELECT SUM(e.fee_amount)
        FROM engagements AS e
        JOIN engagement_staff AS s ON s.engagement_id = e.engagement_id
        WHERE e.fiscal_year = 2026) AS fees_after_staff_join;
```

**What it returns.** The correct fee total is 1,849,175.00. After the join it is 6,089,615.00, about three times as large, because each fee is counted once for each person on the engagement.

The same thing happens in `retailwh`, where `bridge_product_tag` holds 468 rows for 262 products. Each product has one or more tags, so a sale of a tagged product is counted once for each tag. Runs on `retailwh`.

```sql
SELECT (SELECT SUM(net_amount_usd) FROM fact_sales) AS sales_correct,
       (SELECT SUM(f.net_amount_usd)
        FROM fact_sales AS f
        JOIN bridge_product_tag AS b ON b.product_key = f.product_key)
         AS sales_after_tag_join;
```

**What it returns.** 38,834,618.54 for the correct total and 56,569,237.09 after the tag join. The fix is to keep each measure on the fact table and use the bridge only for filtering, or for counts that should count each tag, such as a count of tags per product. In Power BI, a many-to-many relationship through a bridge needs the same care, because a visual that groups by tag will show each sale once per tag, which is correct for that visual and wrong for a total.

## Slowly changing dimensions: what the row said at the time

Customers move, change tiers and change segments. A **slowly changing dimension** keeps a row for each version of a customer, with the dates each version was valid. `retailwh` does this in `dim_customer`: 12,000 customers, and 5,314 of them have more than one version.

Customer C000011 has three versions. Its loyalty tier changed from Bronze to Silver in September 2026, and its city changed from Birmingham to London in December 2022. The query below lists those versions. Runs on `retailwh`.

```sql
SELECT customer_key, loyalty_tier, city, valid_from, valid_to, is_current
FROM dim_customer
WHERE customer_id = 'C000011'
ORDER BY valid_from;
```

**What it returns.** Three rows. The first two are not current, and the third, with `is_current = 1`, is the version in effect today. The sales join depends on what you want to know. Joining the fact to `customer_key` reports each sale against the version that was in effect when it happened. That is the right answer for "what did Bronze customers buy?"

The next query uses the fact-to-version join, grouped by the version's attributes. Runs on `retailwh`.

```sql
SELECT v.loyalty_tier, v.city, COUNT(*) AS sales
FROM fact_sales AS f
JOIN dim_customer AS v ON v.customer_key = f.customer_key
WHERE v.customer_id = 'C000011'
GROUP BY v.loyalty_tier, v.city
ORDER BY v.loyalty_tier, v.city;
```

**What it returns.** Bronze in Birmingham: 16 sales. Bronze in London: 46 sales. Silver in London: 4 sales. Those 66 sales add up to the customer's total.

To report every sale under the customer's **current** tier and city, join the same history to the current version instead. The next query does that. Runs on `retailwh`.

```sql
SELECT cur.loyalty_tier, cur.city, COUNT(*) AS sales
FROM fact_sales AS f
JOIN dim_customer AS v   ON v.customer_key = f.customer_key
JOIN dim_customer AS cur ON cur.customer_id = v.customer_id
                        AND cur.is_current = 1
WHERE v.customer_id = 'C000011'
GROUP BY cur.loyalty_tier, cur.city;
```

**What it returns.** All 66 sales under Silver in London. Both answers are correct. They answer different questions, so label each report with which one it shows. A department reorganization works the same way: a department that moves to a new division should keep its history under the old division.

## Bidirectional filters and ambiguous paths

Each relationship in a model has a direction, the way a slicer filters the table on its far side. A **bidirectional** relationship filters both ways. Used carelessly, it creates loops, and when two paths lead from one table to another, Power BI cannot tell which one a total should follow. The total then depends on which visual asked for it.

The practical rule is to keep relationships single-direction from the dimension to the fact, which is the star shape in the first section. Turn on a bidirectional filter only when a specific measure needs it, put that choice in the measure, and test the total against a SQL query on the source. A relationship that exists for convenience is usually the one that gives the wrong number.

## Checks that catch wrong totals

Build these into the model before anyone reads a report:

1. **Reconcile the subledger to the general ledger.** Invoices billed in FY2026 should equal the revenue posted from invoice entries. In `cpafirm` both are 3,919,677.50. Runs on `cpafirm`.

```sql
SELECT (SELECT SUM(total_amount)
        FROM invoices
        WHERE fiscal_year = 2026) AS invoiced,
       (SELECT SUM(l.credit - l.debit)
        FROM gl_journal_lines AS l
        JOIN gl_journal_entries AS e ON e.journal_entry_id = l.journal_entry_id
        JOIN gl_accounts AS a        ON a.gl_account_id = l.gl_account_id
        WHERE e.source_type = 'Invoice'
          AND e.fiscal_year = 2026
          AND a.account_type = 'Revenue') AS revenue_from_invoice_entries;
```

2. **Count the rows.** A table built from a source should have the same number of rows as the source, or a known, explained difference.
3. **Check the grain.** Count the rows, then count the distinct values of the key that defines the grain. The two numbers must match.
4. **Look for orphans.** A child row with no parent is a broken link, and it drops out of any report that joins to the parent.

> Exercise: Show the net sales in USD for each fiscal year, rounded to whole dollars, with the number of sale lines. Join the sales to the date table on the order date key. Earliest year first.


## Try it

Run these on the databases named in each line. Change one thing at a time and check the result.

1. **Runs on `nonprofit`.** Run the budget against actual query again with `fiscal_year = 2025`. Which expense accounts were over budget last year? Is food purchases over budget again?
2. **Runs on `cpafirm`.** Add `'2026-09-30'` to the list of month-ends in the cash balance query. Does the balance on that date look like a continuation of the trend?
3. **Runs on `cpafirm`.** Count the days in fiscal 2026. The answer should match the number of days from 1 July 2025 to 30 June 2026.

```sql
SELECT COUNT(*) AS days_in_fy2026
FROM fiscal_calendar
WHERE fiscal_year = 2026;
```

For the model build itself, read [Power BI for finance teams](/analyze/power-bi-for-finance). For the measures that sit on top of a model like this, read [DAX for financial reporting](/analyze/dax-financial-reporting).
