Skip to content

Or via Elementary: Fix ROAS metric: Convert historical_orders from cents to dollars - #988

Open
elementary-data-demo[bot] wants to merge 1 commit into
masterfrom
elementary-fix-roas-unit-mismatch
Open

Or via Elementary: Fix ROAS metric: Convert historical_orders from cents to dollars#988
elementary-data-demo[bot] wants to merge 1 commit into
masterfrom
elementary-fix-roas-unit-mismatch

Conversation

@elementary-data-demo

Copy link
Copy Markdown

Problem

The orders model unites two sources with incompatible units:

  • historical_orders: stores amounts in cents (e.g., 10000 cents = $100)
  • real_time_orders: stores amounts in dollars (e.g., 100 = $100)

This unit mismatch corrupts the RETURN_ON_ADVERTISING_SPEND metric in cpa_and_roas, which calculates: attribution_revenue / total_spend. When real-time orders (100× smaller in raw values) mix with historical data, ROAS becomes drastically inaccurate.

Observed Impact: Average ROAS dropped from 65.166 to 0.145 as the proportion of real-time orders increased.

Solution

Apply the cents_to_dollars macro to all monetary fields in historical_orders.sql, ensuring both historical and real-time orders return values in dollars (AUD).

Changes

  • historical_orders.sql: Added explicit column-level conversions using cents_to_dollars() macro for all amount columns
  • schema.yml: Updated descriptions to reflect AUD currency and removal of "in cents" notes

Testing

After merge:

  • ROAS values should stabilize to historical baseline (~65)
  • Column anomaly test on RETURN_ON_ADVERTISING_SPEND should pass
  • All downstream revenue metrics should normalize

Related Issues

  • Column anomalies incident on cpa_and_roas.RETURN_ON_ADVERTISING_SPEND (11 failures since June 8)

    Created by: mika+demo@elementary-data.com

The orders model unions historical_orders (amounts in cents) with
real_time_orders (amounts in dollars), creating a unit mismatch that
corrupts downstream calculations.

Apply the cents_to_dollars macro to all monetary fields in
historical_orders, matching the conversion in real_time_orders. This
ensures both sources produce values in the same unit (AUD).

Fixes:
- Corrupted RETURN_ON_ADVERTISING_SPEND metric (dropped 65.166 → 0.145)
- 11 consecutive column anomaly test failures on cpa_and_roas
- Downstream revenue-attribution calculations in dashboards"
@MikaKerman MikaKerman changed the title Mika via Elementary: Fix ROAS metric: Convert historical_orders from cents to dollars Or via Elementary: Fix ROAS metric: Convert historical_orders from cents to dollars Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants