Labor cost by month, drillable to a person
The report the module exists for. Cost by department by month, footed to the same total the ledger tie proves, with the unassigned money named instead of spread.
◆ The reportcost by department by month, unassigned named, rows openable.
This is the page the module exists to produce. Total employer cost, by department, by month. The bottom row is the same total the ledger tie proves, so the trend inherits the proof. Departments open to people on click; Sales is shown open.
| department | Mar 2026 | Apr 2026 | May 2026 |
|---|---|---|---|
| −Sales | 2,061,340.00 | 2,088,115.00 | 2,149,257.31 |
| Alvarez, R. | 14,890.00 | 14,890.00 | 15,412.50 |
| Chen, M. | 13,240.00 | 13,760.00 | 13,760.00 |
| 141 others | 2,033,210.00 | 2,059,465.00 | 2,120,084.81 |
| +Technology Delivery | 1,377,895.00 | 1,391,220.00 | 1,410,006.88 |
| 112 people | 1,377,895.00 | 1,391,220.00 | 1,410,006.88 |
| +Support | 1,061,110.00 | 1,071,995.00 | 1,094,035.96 |
| 96 people | 1,061,110.00 | 1,071,995.00 | 1,094,035.96 |
| Unassigned | 0.00 | 0.00 | 9,841.93 |
| Total, ties to ledger | 4,500,345.00 | 4,551,330.00 | 4,663,142.08 |
Two things a delivered trend cannot do are on this table. The unassigned row appears the month it happens, with an amount: money charged to no department, visible instead of spread invisibly across defaults. And every month column footing to a ledger-proved total means a department head arguing with a number is arguing with the books, not with an analyst. Sample values are illustrative, never client data.
◆ The query behind itone aggregation of the fact, nothing else.
-- employer cost by department by month, unassigned kept visible
SELECT COALESCE(cc.cost_center_name, 'Unassigned') AS department,
d.fiscal_period,
SUM(f.amount) AS employer_cost
FROM fct_payroll_result_line f
JOIN dim_date d ON f.accounting_date_key = d.date_key
JOIN dim_pay_component c ON f.pay_component_key = c.pay_component_key
LEFT JOIN dim_cost_center cc ON f.cost_center_key = cc.cost_center_key
WHERE d.fiscal_period BETWEEN '2026-03' AND '2026-05'
AND c.affects_ledger
GROUP BY 1, 2
ORDER BY 1, 2
The left join to department is the honesty mechanism: an inner join would silently drop unassigned lines, and the report would foot to the wrong total while looking complete. Add worker to the grouping and the same query returns the person level. That is the whole difference between the summary and the drill.
- employer cost
- Gross pay plus the employer taxes and benefit share. What the books carry.
- foot
- To add a column to its total. A report foots when the pieces sum to the stated total.
- unassigned
- Cost charged to no department. Named as a row rather than defaulted away.
- drill
- Opening a summary number to the rows inside it.
- left join
- A join keeping every row from the first table whether or not the second matches.
- fiscal period
- The accounting month an amount belongs to.
- tie
- A check that two independently built totals agree.
- fact
- A table of measured amounts. Here, pay.