Create time series for each customer
This SQL model captures the monthly recurring revenue (MRR) trend for each customer, including the change in MRR, and provides a rank based on the MRR. It also considers the customer's subscription status and cancellation date.
- Grain
- See the notes
- Built from
- 6Raw tables
- 1Staging
- 4Core
- 1Analytics
- Reads from Stripe
- incrementalcouponplansubscriptionsubscription_discountsubscription_item
- Ships as
- Weld and dbt SQL, open source on GitHub
1-- core.stripe.mrr_time_series
2-- Create time series for each customer. This SQL model captures the monthly
3-- recurring revenue (MRR) trend for each customer, including the change in MRR, and
4-- provides a rank based on the MRR. It also considers the customer's subscription
5-- status and cancellation date.
6--
7-- The monthly calendar starts at the earliest subscription start month in
8-- the data and runs to the current month.
9--
10-- From the weld.app template library, corrected. Not reconciled against
11-- Stripe; check the output against the source before relying on it.
12
13with
14 time_series as (
15 select
16 month
17 from
18 unnest (
19 generate_date_array(
20 (select min(start_date_month) from {{core.stripe.mrr_active_subscriptions}})
21 , current_date
22 , interval 1 month
23 )
24 ) as month
25 )
26 , time_series_customer as (
27 select
28 *
29 from
30 (
31 select distinct
32 (customer_id) customer_id
33 , month
34 from
35 {{core.stripe.mrr_active_subscriptions}}
36 cross join time_series
37 order by
38 customer_id
39 , month
40 )This model and the 5 it depends on. Deploy them together; refs like {{staging.…}} resolve to the matching folders in Weld, and the dbt view uses source() and ref().
How it counts. And where it stops.
By using this model, businesses can gain insights into their customer's MRR progression, helping in understanding the customer's lifetime value, churn patterns, and overall business health. The time series analysis also assists in predicting future revenue patterns and making informed business decisions.
Raw tables it reads
- raw.forex_eur.incremental
- raw.stripe.coupon
- raw.stripe.plan
- raw.stripe.subscription
- raw.stripe.subscription_discount
- raw.stripe.subscription_item
Put Stripe in front
of your agents.
Connect Stripe, deploy the models, and ask questions in Claude, Cursor or ChatGPT. Free for 14 days, no credit card.