Skip to content

Feature/financial metrics clv revenue#46

Open
ijac13 wants to merge 3 commits intomainfrom
feature/financial-metrics-clv-revenue
Open

Feature/financial metrics clv revenue#46
ijac13 wants to merge 3 commits intomainfrom
feature/financial-metrics-clv-revenue

Conversation

@ijac13
Copy link

@ijac13 ijac13 commented Apr 7, 2025

Trust Issues: How Jaffle Shop Rebuilt Stakeholder Confidence with Recce

📌 Summary

This PR resolves a critical issue in how revenue and customer lifetime value (CLV) were being calculated across the customers, customer_segments, customer_order_pattern, and finance_revenue models.

We identified that:

  • All order statuses were included in revenue and CLV metrics—including unfulfilled or returned orders.
  • Coupon payments were mistakenly treated as revenue, inflating metrics across both marketing and finance reports.
    This broke trust in our data. Both marketing and finance were misled for months.

✅ Solution

We’ve introduced three key changes:

  1. Filter for completed orders only
    • Ensures only fulfilled purchases are included in CLV and revenue.
  2. Add net_customer_lifetime_value
  • Captures actual revenue (excluding coupon payments).
  • Existing dashboards using gross CLV remain functional.
  1. Create finance_revenue model
  • Gross and net revenue metrics are now clearly separated.
  • Accurate reporting for finance, without mixing marketing assumptions.

👁️ Impacted and validation

  • See modified models in Recce Summary

  • With these 4 modified models, only customer_segments is impacted. See Breaking Change Analysis + Column-Level Lineage in Recce: Apr 7 Screenshot from Notion

  • Validation checks are included in Checklist

Supporting Resources

@ijac13 ijac13 requested a review from even-wei April 7, 2025 09:15
@even-wei even-wei changed the base branch from duckdb to main April 7, 2025 09:18
even-wei and others added 2 commits April 7, 2025 17:21
Signed-off-by: even-wei <evenwei@infuseai.io>
Signed-off-by: popcorny <celu@infuseai.io>
@recce-cloud
Copy link

recce-cloud bot commented Oct 31, 2025

Summary

PR #46 addresses critical calculation issues in revenue and customer lifetime value (CLV) metrics across the data warehouse. The changes filter for completed orders only, distinguish between gross and net revenue by excluding coupon payments, and introduce a new finance_revenue model. However, the recalculation results in a significant 32-35% reduction in average customer lifetime value, which requires validation to ensure alignment with business requirements.


Key Changes

customers model: row_count_diff confirms the model maintains 1,856 rows (unchanged), but query_diff reveals average customer_lifetime_value decreased from $5,639.76 to $3,799.30 (-32.67%) for customers acquired in late 2019. This aligns with the intentional filter for completed orders only and exclusion of coupon revenue.

customer_segments model: Two new columns added (NET_VALUE_SEGMENT, NET_CUSTOMER_LIFETIME_VALUE) to reflect net revenue calculations. Row count remains stable at 1,856 records.

finance_revenue (new model): Added table with 280,844 rows, establishing a dedicated model for separating gross and net revenue metrics.

stg_payments staging model: Added COUPON_AMOUNT column to properly separate coupon payments from actual revenue.


Impact Analysis

Lineage visualization showing 10 models in the data lineage, with 3 modified, 1 new, and 6 downstream impacted models:

graph LR
    raw_payments["raw_payments<br/>(source)"]:::unchanged
    stg_customers["stg_customers<br/>(view)"]:::unchanged
    stg_orders["stg_orders<br/>(view)"]:::unchanged
    stg_payments["stg_payments<br/>(view)"]:::modified
    customers["customers<br/>(table)"]:::modified
    orders["orders<br/>(table)"]:::impacted
    customer_order_pattern["customer_order_pattern<br/>(table)"]:::impacted
    customer_segments["customer_segments<br/>(table)"]:::modified
    orders_daily_summary["orders_daily_summary<br/>(incremental)"]:::impacted
    finance_revenue["finance_revenue<br/>(table)"]:::added

    raw_payments --> stg_payments
    stg_customers --> customers
    stg_orders --> customers
    stg_payments --> customers
    customers --> customer_order_pattern
    customers --> customer_segments
    stg_orders --> orders
    stg_payments --> orders
    orders --> orders_daily_summary
    stg_orders --> finance_revenue
    stg_payments --> finance_revenue

    classDef added fill:#d4edda,stroke:#28a745,color:#000000
    classDef removed fill:#f8d7da,stroke:#dc3545,color:#000000
    classDef modified fill:#fff3cd,stroke:#ffc107,color:#000000
    classDef impacted fill:#ffffff,stroke:#ffc107,color:#000000
    classDef unchanged fill:#ffffff,stroke:#d3d3d3,color:#999999
Loading

Downstream Impact:

  • 🟡 7 models impacted: customer_order_pattern, orders, orders_daily_summary, and others depend on modified upstream models
  • ⚠️ Schema expansion: 4 new columns added across modified models (NET_CUSTOMER_LIFETIME_VALUE, NET_VALUE_SEGMENT, COUPON_AMOUNT)
  • Row count consistency: row_count_diff confirms existing models maintain data volume—customers stays at 1,856 rows, customer_segments at 1,856 rows, orders at 280,844 rows
  • 📝 Incremental model: orders_daily_summary is unmodified but impacted by upstream changes (expected behavior for incremental models)

☑️ Checklist

Name Run Status Impact Analysis
Model schema of customers, orders and modified nodes PASSED ✅ Schema changes are expected—4 new columns added across modified models to distinguish gross/net revenue
Row count of customers, orders and modified table model PASSED ✅ All existing models maintain row consistency: customers (1,856), orders (280,844), customer_segments (1,856)
Value diff of customers 🔴 FAILED 🔴 Critical: Only 22 out of 1,856 records (1.19%) match for customer_lifetime_value between environments—indicates intentional recalculation affecting 98.8% of customer records
Query diff of customers avg lifetime value 🔴 FAILED 🔴 Critical: Average customer_lifetime_value decreased 32-35% across all cohorts (e.g., -32.67% for week 2019-12-30)—confirms systematic reduction from order status and coupon exclusion filters

🔍 Suggested Actions

  • Validate customer_lifetime_value reduction against business requirements: The 32-35% decrease in average CLV across all customer cohorts (per query_diff results) must be confirmed as intentional. Verify that filtering for completed orders only and excluding coupons aligns with revenue reporting policies.
  • Review finance_revenue model logic: Run profile_diff on finance_revenue.gross_revenue and finance_revenue.net_revenue columns to confirm the coupon exclusion is correctly applied and no edge cases are missed.
  • Test downstream impact on dashboards: Check customer_segments reports and customer_order_pattern queries to ensure CLV-dependent dashboards handle the 32-35% metric change gracefully without breaking visualizations.
  • Verify coupon treatment in stg_payments: Run query_diff on the COUPON_AMOUNT column added to stg_payments to ensure all coupon records are correctly identified and properly excluded from revenue calculations.
  • Confirm orders table filtering consistency: Validate that the "completed orders only" filter is consistently applied across customers, customer_segments, and orders models by running spot-check queries on specific order IDs with non-completed statuses.
    Please use the link below to launch your Recce Cloud session.

Launch Recce Cloud Session


Was this summary helpful? 👍 👎

@popcornylu

This comment was marked as duplicate.

@DataRecce DataRecce deleted a comment from github-actions bot Jan 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants