PnL Metrics
Computes standardized PnL metrics (margins, totals, and percentages) on top of the hierarchical PnL Rollup.
Purpose
Produce a canonical set of PnL metrics (gross margin, contribution margin, total cost, EBITDA, and related percentages) derived from the rolled-up PnL data.
This model encodes financial definitions once so that margins and ratios are consistent across all reports, dashboards, and analyses.
Business Logic
- Start from the fully aggregated GL hierarchy provided by pnl_rollup
- Compute absolute PnL metrics using reserved GL account IDs:
- Gross Margin
3000= Revenue1000− COGS2000 - Contribution Margin
5000= Gross Margin3000− Commercial Costs4000 - Total Cost
7000= COGS2000+ Commercial Costs4000+ Fixed Costs6000 - EBITDA
8000= Contribution Margin5000− Fixed Costs6000
- Gross Margin
- Append derived metric rows to the base PnL data
- Compute percentage KPIs relative to Revenue
1000:- COGS %
- Gross margin %
- Commercial costs %
- Contribution margin %
- Fixed costs %
- Total cost %
- EBITDA %
- Percentage calculations:
- Use revenue as denominator
- Protect against division by zero
- Output includes both:
- Absolute values (amounts)
- Relative values (percentages)
Final dataset is ordered by value type, date, and GL account.
Output Contract
Definitions
The output contract has the same setup as PnL Rollup but only includes the absolute and relative margins.
| Column | Description |
|---|---|
| date | Date represented as YYYY-MM-DD. Links to Dates semantic contract |
| gl_id | GL Account identifier. Links to GL Accounts semantic contract |
| gl_account | GL Account name at any hierarchy level. Links to GL Accounts semantic contract |
| value_type_id | Value Type identifier. Links to Value Type semantic contract |
| type | Value Type name. Links to Value Type semantic contract |
| amount | Aggregated amount including all child accounts |
Sample & Implementation
| date | gl_id | gl_account | value_type_id | value_type | amount |
|---|---|---|---|---|---|
| 2025-01-01 | 2001 | cogs_pct | 1 | actuals | 0.0425419403037417 |
| 2025-01-01 | 3000 | gross_margin | 1 | actuals | 13159474.0 |
| 2025-01-01 | 3001 | gross_margin_pct | 1 | actuals | 0.9574580596962583 |
| 2025-01-01 | 4001 | commercial_costs_pct | 1 | actuals | 0.016153021301092 |
| 2025-01-01 | 5000 | contribution_margin | 1 | actuals | 13159474.0 |
| 2025-01-01 | 5001 | contribution_margin_pct | 1 | actuals | 0.9574580596962583 |
| 2025-01-01 | 6001 | fixed_costs_pct | 1 | actuals | 0.022506038556834754 |
| 2025-01-01 | 7000 | total_cost | 1 | actuals | 1116041.0 |
| 2025-01-01 | 7001 | total_cost_pct | 1 | actuals | 0.08120100016166845 |
| 2025-01-01 | 8000 | ebitda | 1 | actuals | 13159474.0 |
| 2025-01-01 | 8001 | ebitda_pct | 1 | actuals | 0.9574580596962583 |
Dependencies
- Transformations: PnL Rollup