PnL Rollup
Recursively aggregates PnL values across the GL account hierarchy for reporting.
Purpose
Produce a reporting-ready PnL dataset where amounts are available at all GL hierarchy levels, not just leaf accounts. This model centralizes hierarchical aggregation logic so downstream consumers do not need to reimplement it.
Business Logic
- Start from atomic PnL entries at the lowest GL account level
- Use the GL account hierarchy to identify parent–child relationships
- Recursively propagate amounts from child accounts to all parent accounts
- Aggregate amounts per:
- Date
- GL account (leaf and parent)
- Value Type
Output Contract
Definitions
| 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 | 1000 | revenue | 1 | actuals | 13744178 |
| 2025-01-01 | 1010 | subscriptions | 1 | actuals | 13743233 |
| 2025-01-01 | 1020 | services | 1 | actuals | 451 |
| 2025-01-01 | 1030 | others | 1 | actuals | 494 |
| 2025-01-01 | 2000 | cogs | 1 | actuals | 584704 |
| 2025-01-01 | 2010 | payment_fees | 1 | actuals | 584236 |
| 2025-01-01 | 2020 | other_costs | 1 | actuals | 468 |
| 2025-01-01 | 4000 | commercial_costs | 1 | actuals | 222010 |
| 2025-01-01 | 4010 | sales | 1 | actuals | 117750 |
| 2025-01-01 | 4011 | sales_staff | 1 | actuals | 107188 |
Dependencies
- Facts: PnL
- Semantic Layers: GL Accounts