From 653666abade0089e57e703e309462248834617c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oriol=20Roqu=C3=A9=20Paniagua?= Date: Thu, 24 Apr 2025 12:42:21 +0000 Subject: [PATCH] Merged PR 5044: Switch Projected Created Bookings to Billable Bookings # Description Switches Created Bookings to Billable Bookings in the scope of Projected Bookings. I opted for hard switching (thus removing Projected Created Bookings) altogether to avoid having unused models in production. This aims to set the ground to include, in the future, APIs Billable Bookings. Impact in KPIs: * `int_kpis__agg_daily_created_bookings` now is `int_kpis__agg_daily_billable_bookings`. Aside from the name change, it's reduced to 4 metrics to just one. Schema changes also apply. Impact in Projected KPIs: * `int_kpis_projected__agg_daily_created_bookings` now is `int_kpis_projected__agg_daily_billable_bookings`. Fields are also renamed accordingly. * `int_kpis_projected__agg_monthly_created_bookings` now is `int_kpis_projected__agg_monthly_billable_bookings`. Fields are also renamed accordingly. * Schema file is also updated accordingly. Impact on new model for Growth Score: * `int_created_bookings_growth_score_by_deal` now is `int_billable_bookings_growth_score_by_deal`. Fields are also renamed accordingly. * Schema is also updated accordingly. Note that since the end model `int_billable_bookings_growth_score_by_deal` is not used at the moment in reporting, there's no user-facing impact. Also, the rest of modified models are not used for other purposes. # Checklist - [X] The edited models and dependants run properly with production data. - [X] The edited models are sufficiently documented. - [X] The edited models contain PK tests, and I've ran and passed them. - [X] I have checked for DRY opportunities with other models and docs. - [X] I've picked the right materialization for the affected models. # Other - [ ] Check if a full-refresh is required after this PR is merged. Related work items: #29374 --- ...billable_bookings_growth_score_by_deal.sql | 115 ++++++++++++++++++ ..._created_bookings_growth_score_by_deal.sql | 113 ----------------- models/intermediate/cross/schema.yml | 58 ++++----- .../int_kpis__agg_daily_billable_bookings.sql | 19 +++ .../int_kpis__agg_daily_created_bookings.sql | 23 ---- ...rojected__agg_daily_billable_bookings.sql} | 78 ++++++------ ...jected__agg_monthly_billable_bookings.sql} | 32 ++--- models/intermediate/kpis/projected/schema.yml | 88 +++++++------- models/intermediate/kpis/schema.yml | 27 +--- 9 files changed, 269 insertions(+), 284 deletions(-) create mode 100644 models/intermediate/cross/int_billable_bookings_growth_score_by_deal.sql delete mode 100644 models/intermediate/cross/int_created_bookings_growth_score_by_deal.sql create mode 100644 models/intermediate/kpis/int_kpis__agg_daily_billable_bookings.sql delete mode 100644 models/intermediate/kpis/int_kpis__agg_daily_created_bookings.sql rename models/intermediate/kpis/projected/{int_kpis_projected__agg_daily_created_bookings.sql => int_kpis_projected__agg_daily_billable_bookings.sql} (70%) rename models/intermediate/kpis/projected/{int_kpis_projected__agg_monthly_created_bookings.sql => int_kpis_projected__agg_monthly_billable_bookings.sql} (67%) diff --git a/models/intermediate/cross/int_billable_bookings_growth_score_by_deal.sql b/models/intermediate/cross/int_billable_bookings_growth_score_by_deal.sql new file mode 100644 index 0000000..99aff3e --- /dev/null +++ b/models/intermediate/cross/int_billable_bookings_growth_score_by_deal.sql @@ -0,0 +1,115 @@ +{{ config(materialized="table", unique_key=["end_date", "id_deal"]) }} +with + int_kpis_projected__agg_monthly_billable_bookings as ( + select * + from {{ ref("int_kpis_projected__agg_monthly_billable_bookings") }} + where dimension = 'by_deal' and dimension_value <> 'UNSET' + ), + int_kpis__agg_monthly_billable_bookings as ( + select * + from {{ ref("int_kpis__agg_monthly_billable_bookings") }} + where dimension = 'by_deal' and dimension_value <> 'UNSET' + ), + billable_bookings_per_month_with_projection as ( + select + start_date, + end_date, + dimension_value as id_deal, + current_month_projected_billable_bookings + as current_month_billable_bookings, + current_month_projected_billable_bookings + / sum(current_month_projected_billable_bookings) over ( + partition by end_date order by end_date + ) as current_month_share_billable_bookings, + historical_monthly_mean_absolute_error as projection_mean_absolute_error, + historical_monthly_mean_absolute_percentage_error + as projection_mean_absolute_percentage_error, + true as are_billable_bookings_projected + from int_kpis_projected__agg_monthly_billable_bookings + union all + select + start_date, + end_date, + dimension_value as id_deal, + billable_bookings as current_month_billable_bookings, + billable_bookings / sum(billable_bookings) over ( + partition by end_date order by end_date + ) as current_month_share_billable_bookings, + null as projection_mean_absolute_error, + null as projection_mean_absolute_percentage_error, + false as are_billable_bookings_projected + from int_kpis__agg_monthly_billable_bookings + ), + billable_bookings_growth_score as ( + select + start_date, + end_date, + id_deal, + -- Billable Bookings (Absolute) -- + current_month_billable_bookings, + avg(current_month_billable_bookings) over ( + partition by id_deal + order by end_date asc + rows between 3 preceding and 1 preceding + ) as prior_3_months_avg_monthly_billable_bookings, + current_month_billable_bookings + / avg(current_month_billable_bookings) over ( + partition by id_deal + order by end_date asc + rows between 3 preceding and 1 preceding + ) + - 1 as growth_vs_prior_3_avg_billable_bookings, + + -- Share of Billable Bookings per Deal over Total -- + current_month_share_billable_bookings, + avg(current_month_share_billable_bookings) over ( + partition by id_deal + order by end_date asc + rows between 3 preceding and 1 preceding + ) as prior_3_months_avg_monthly_share_billable_bookings, + current_month_share_billable_bookings + / avg(current_month_share_billable_bookings) over ( + partition by id_deal + order by end_date asc + rows between 3 preceding and 1 preceding + ) + - 1 as growth_vs_prior_3_avg_share_billable_bookings, + -- Projection Reference -- + projection_mean_absolute_error, + projection_mean_absolute_percentage_error, + are_billable_bookings_projected + from billable_bookings_per_month_with_projection + ) +select + start_date, + end_date, + id_deal, + -- Billable Bookings (Absolute) -- + current_month_billable_bookings, + prior_3_months_avg_monthly_billable_bookings, + -- Share of Billable Bookings per Deal over Total -- + current_month_share_billable_bookings, + prior_3_months_avg_monthly_share_billable_bookings, + -- Specific Growth Scores -- + growth_vs_prior_3_avg_billable_bookings, + growth_vs_prior_3_avg_share_billable_bookings, + -- Combined Growth Score -- + least( + greatest( + coalesce( + ( + growth_vs_prior_3_avg_billable_bookings + + growth_vs_prior_3_avg_share_billable_bookings + ) + / 2, + 0 + ), + -1 + ), + 1 + ) as growth_score, + -- Projection Reference -- + projection_mean_absolute_error, + projection_mean_absolute_percentage_error, + are_billable_bookings_projected +from billable_bookings_growth_score diff --git a/models/intermediate/cross/int_created_bookings_growth_score_by_deal.sql b/models/intermediate/cross/int_created_bookings_growth_score_by_deal.sql deleted file mode 100644 index 65f22c2..0000000 --- a/models/intermediate/cross/int_created_bookings_growth_score_by_deal.sql +++ /dev/null @@ -1,113 +0,0 @@ -{{ config(materialized="table", unique_key=["end_date", "id_deal"]) }} -with - int_kpis_projected__agg_monthly_created_bookings as ( - select * - from {{ ref("int_kpis_projected__agg_monthly_created_bookings") }} - where dimension = 'by_deal' and dimension_value <> 'UNSET' - ), - int_kpis__agg_monthly_created_bookings as ( - select * - from {{ ref("int_kpis__agg_monthly_created_bookings") }} - where dimension = 'by_deal' and dimension_value <> 'UNSET' - ), - created_bookings_per_month_with_projection as ( - select - start_date, - end_date, - dimension_value as id_deal, - current_month_projected_created_bookings as current_month_created_bookings, - current_month_projected_created_bookings - / sum(current_month_projected_created_bookings) over ( - partition by end_date order by end_date - ) as current_month_share_created_bookings, - historical_monthly_mean_absolute_error as projection_mean_absolute_error, - historical_monthly_mean_absolute_percentage_error - as projection_mean_absolute_percentage_error, - true as are_created_bookings_projected - from int_kpis_projected__agg_monthly_created_bookings - union all - select - start_date, - end_date, - dimension_value as id_deal, - created_bookings as current_month_created_bookings, - created_bookings / sum(created_bookings) over ( - partition by end_date order by end_date - ) as current_month_share_created_bookings, - null as projection_mean_absolute_error, - null as projection_mean_absolute_percentage_error, - false as are_created_bookings_projected - from int_kpis__agg_monthly_created_bookings - ), - created_bookings_growth_score as ( - select - start_date, - end_date, - id_deal, - -- Created Bookings (Absolute) -- - current_month_created_bookings, - avg(current_month_created_bookings) over ( - partition by id_deal - order by end_date asc - rows between 3 preceding and 1 preceding - ) as prior_3_months_avg_monthly_created_bookings, - current_month_created_bookings / avg(current_month_created_bookings) over ( - partition by id_deal - order by end_date asc - rows between 3 preceding and 1 preceding - ) - - 1 as growth_vs_prior_3_avg_created_bookings, - - -- Share of Created Bookings per Deal over Total -- - current_month_share_created_bookings, - avg(current_month_share_created_bookings) over ( - partition by id_deal - order by end_date asc - rows between 3 preceding and 1 preceding - ) as prior_3_months_avg_monthly_share_created_bookings, - current_month_share_created_bookings - / avg(current_month_share_created_bookings) over ( - partition by id_deal - order by end_date asc - rows between 3 preceding and 1 preceding - ) - - 1 as growth_vs_prior_3_avg_share_created_bookings, - -- Projection Reference -- - projection_mean_absolute_error, - projection_mean_absolute_percentage_error, - are_created_bookings_projected - from created_bookings_per_month_with_projection - ) -select - start_date, - end_date, - id_deal, - -- Created Bookings (Absolute) -- - current_month_created_bookings, - prior_3_months_avg_monthly_created_bookings, - -- Share of Created Bookings per Deal over Total -- - current_month_share_created_bookings, - prior_3_months_avg_monthly_share_created_bookings, - -- Specific Growth Scores -- - growth_vs_prior_3_avg_created_bookings, - growth_vs_prior_3_avg_share_created_bookings, - -- Combined Growth Score -- - least( - greatest( - coalesce( - ( - growth_vs_prior_3_avg_created_bookings - + growth_vs_prior_3_avg_share_created_bookings - ) - / 2, - 0 - ), - -1 - ), - 1 - ) as growth_score, - -- Projection Reference -- - projection_mean_absolute_error, - projection_mean_absolute_percentage_error, - are_created_bookings_projected -from created_bookings_growth_score diff --git a/models/intermediate/cross/schema.yml b/models/intermediate/cross/schema.yml index c03625f..67a419d 100644 --- a/models/intermediate/cross/schema.yml +++ b/models/intermediate/cross/schema.yml @@ -3225,18 +3225,18 @@ models: When precision and recall are far apart, the F2 score will be closer to the lower of the two. - - name: int_created_bookings_growth_score_by_deal + - name: int_billable_bookings_growth_score_by_deal description: | - This model computes the growth score of the created bookings for each deal. + This model computes the growth score of the billable bookings for each deal. The growth score is computed as the average between: - - The created bookings of a given month vs. the average of the previous + - The billable bookings of a given month vs. the average of the previous 3 months. - - The share a deal has in terms of created bookings of a given month + - The share a deal has in terms of billable bookings of a given month if compared to the rest of the deals vs. the average of the previous 3 months. The growth score is capped between -1 and 1. It is important to note that if we check the current month, the count of - created bookings and the corresponding share will be based on the projection, + billable bookings and the corresponding share will be based on the projection, rather than the actual figure. In this case, the MAE and MAPE of the projected value are indicated in the model. While the growth score is computed at a monthly basis, the value will update @@ -3274,12 +3274,12 @@ models: data_tests: - not_null - - name: current_month_created_bookings + - name: current_month_billable_bookings data_type: integer description: | - Monthly created bookings. If the month is in progress + Monthly billable bookings. If the month is in progress then this value corresponds to the projected figure. - This is indicated by "are_created_bookings_projected" + This is indicated by "are_billable_bookings_projected" flag. data_tests: - not_null @@ -3287,10 +3287,10 @@ models: min_value: 0 strictly: false - - name: prior_3_months_avg_monthly_created_bookings + - name: prior_3_months_avg_monthly_billable_bookings data_type: integer description: | - Average of the created bookings for the previous 3 months. + Average of the billable bookings for the previous 3 months. If the selected range is from 1st April 2025 to 30th April 2025, then this average will be based between 1st January 2025 to 31st March 2025. @@ -3299,12 +3299,12 @@ models: min_value: 0 strictly: false - - name: current_month_share_created_bookings + - name: current_month_share_billable_bookings data_type: decimal description: | - Share of the created bookings for a given deal in the current month. + Share of the billable bookings for a given deal in the current month. If the month is in progress then this value corresponds to the - projected figure. This is indicated by "are_created_bookings_projected" + projected figure. This is indicated by "are_billable_bookings_projected" flag. data_tests: - not_null @@ -3312,10 +3312,10 @@ models: min_value: 0 strictly: false - - name: prior_3_months_avg_monthly_share_created_bookings + - name: prior_3_months_avg_monthly_share_billable_bookings data_type: decimal description: | - Average of the share of the created bookings for a given deal in the + Average of the share of the billable bookings for a given deal in the previous 3 months. If the selected range is from 1st April 2025 to 30th April 2025, then this average will be based between 1st January 2025 to 31st March 2025. @@ -3324,21 +3324,21 @@ models: min_value: 0 strictly: false - - name: growth_vs_prior_3_avg_created_bookings + - name: growth_vs_prior_3_avg_billable_bookings data_type: decimal description: | - Growth score of the created bookings based purely on the relative - difference between the current month created bookings vs. the + Growth score of the billable bookings based purely on the relative + difference between the current month billable bookings vs. the prior 3 months average. This is a subcomputation of the growth score, for information purposes. It can be null. - - name: growth_vs_prior_3_avg_share_created_bookings + - name: growth_vs_prior_3_avg_share_billable_bookings data_type: decimal description: | - Growth score of the created bookings based purely on the relative - difference between the current month share created bookings vs. the + Growth score of the billable bookings based purely on the relative + difference between the current month share billable bookings vs. the prior 3 months average. This is a subcomputation of the growth score, for information purposes. @@ -3347,10 +3347,10 @@ models: - name: growth_score data_type: decimal description: | - Growth score of the created bookings, based on the average between: - - The created bookings of a given month vs. the average of the previous + Growth score of the billable bookings, based on the average between: + - The billable bookings of a given month vs. the average of the previous 3 months. - - The share a deal has in terms of created bookings of a given month + - The share a deal has in terms of billable bookings of a given month if compared to the rest of the deals vs. the average of the previous 3 months. The growth score is capped between -1 and 1. @@ -3365,7 +3365,7 @@ models: - name: projection_mean_absolute_error data_type: decimal description: | - Mean absolute error of the projection of the created bookings. + Mean absolute error of the projection of the billable bookings. It is null if the month is not in progress or value is projected but there's no prior data to compare the projection against. data_tests: @@ -3376,7 +3376,7 @@ models: - name: projection_mean_absolute_percentage_error data_type: decimal description: | - Mean absolute percentage error of the projection of the created bookings. + Mean absolute percentage error of the projection of the billable bookings. It is null if the month is not in progress or value is projected but there's no prior data to compare the projection against. data_tests: @@ -3384,12 +3384,12 @@ models: min_value: 0 strictly: false - - name: are_created_bookings_projected + - name: are_billable_bookings_projected data_type: boolean description: | - Flag indicating if the created bookings are projected or not. + Flag indicating if the billable bookings are projected or not. If the month is in progress then this value corresponds to the - projected figure. This is indicated by "are_created_bookings_projected" + projected figure. This is indicated by "are_billable_bookings_projected" flag. data_tests: - not_null diff --git a/models/intermediate/kpis/int_kpis__agg_daily_billable_bookings.sql b/models/intermediate/kpis/int_kpis__agg_daily_billable_bookings.sql new file mode 100644 index 0000000..7b04db4 --- /dev/null +++ b/models/intermediate/kpis/int_kpis__agg_daily_billable_bookings.sql @@ -0,0 +1,19 @@ +{% set dimensions = get_kpi_dimensions_per_model("BILLABLE_BOOKINGS") %} + +{{ config(materialized="table", unique_key=["date", "dimension", "dimension_value"]) }} + + +{% for dimension in dimensions %} + select + -- Unique Key -- + date, + {{ dimension.dimension }} as dimension, + {{ dimension.dimension_value }} as dimension_value, + -- Metrics -- + sum(billable_bookings) as billable_bookings + from {{ ref("int_kpis__metric_daily_billable_bookings") }} + group by 1, 2, 3 + {% if not loop.last %} + union all + {% endif %} +{% endfor %} diff --git a/models/intermediate/kpis/int_kpis__agg_daily_created_bookings.sql b/models/intermediate/kpis/int_kpis__agg_daily_created_bookings.sql deleted file mode 100644 index c312a74..0000000 --- a/models/intermediate/kpis/int_kpis__agg_daily_created_bookings.sql +++ /dev/null @@ -1,23 +0,0 @@ -{% set dimensions = get_kpi_dimensions_per_model("CREATED_BOOKINGS") %} - -{{ config(materialized="table", unique_key=["date", "dimension", "dimension_value"]) }} - - -{% for dimension in dimensions %} - select - -- Unique Key -- - date, - {{ dimension.dimension }} as dimension, - {{ dimension.dimension_value }} as dimension_value, - -- Metrics -- - sum(created_bookings) as created_bookings, - sum(cancelled_created_bookings) as cancelled_created_bookings, - sum(not_cancelled_created_bookings) as not_cancelled_created_bookings, - sum(cancelled_created_bookings) - / sum(created_bookings) as cancelled_created_bookings_rate - from {{ ref("int_kpis__metric_daily_created_bookings") }} - group by 1, 2, 3 - {% if not loop.last %} - union all - {% endif %} -{% endfor %} diff --git a/models/intermediate/kpis/projected/int_kpis_projected__agg_daily_created_bookings.sql b/models/intermediate/kpis/projected/int_kpis_projected__agg_daily_billable_bookings.sql similarity index 70% rename from models/intermediate/kpis/projected/int_kpis_projected__agg_daily_created_bookings.sql rename to models/intermediate/kpis/projected/int_kpis_projected__agg_daily_billable_bookings.sql index ab3cb68..8ee9890 100644 --- a/models/intermediate/kpis/projected/int_kpis_projected__agg_daily_created_bookings.sql +++ b/models/intermediate/kpis/projected/int_kpis_projected__agg_daily_billable_bookings.sql @@ -8,8 +8,8 @@ with int_kpis_projected__dimension_dates as ( select * from {{ ref("int_kpis_projected__dimension_dates") }} ), - int_kpis__agg_daily_created_bookings as ( - select * from {{ ref("int_kpis__agg_daily_created_bookings") }} + int_kpis__agg_daily_billable_bookings as ( + select * from {{ ref("int_kpis__agg_daily_billable_bookings") }} ), same_month_trend as ( -- Computes the daily bookings based on the same month trend. @@ -24,17 +24,17 @@ with sum( case when dd.is_available_for_same_month_projection - then coalesce(mm.created_bookings, 0) + then coalesce(mm.billable_bookings, 0) else 0 end ), 0 - ) as same_month_trend_total_created_bookings, + ) as same_month_trend_total_billable_bookings, coalesce( 1.0 * sum( case when dd.is_available_for_same_month_projection - then coalesce(mm.created_bookings, 0) + then coalesce(mm.billable_bookings, 0) else 0 end ) @@ -49,7 +49,7 @@ with 0 ), 0 - ) as same_month_trend_daily_created_bookings, + ) as same_month_trend_daily_billable_bookings, max( case when dd.is_available_for_same_month_projection @@ -58,7 +58,7 @@ with end ) as same_month_trend_total_available_days from int_kpis_projected__dimension_dates dd - inner join int_kpis__agg_daily_created_bookings mm on dd.date = mm.date + inner join int_kpis__agg_daily_billable_bookings mm on dd.date = mm.date group by 1, 2, 3 ), last_7_days_trend as ( @@ -74,27 +74,27 @@ with sum( case when dd.is_available_for_same_month_projection - then coalesce(mm.created_bookings, 0) + then coalesce(mm.billable_bookings, 0) else 0 end ), 0 - ) as last_7_days_trend_total_created_bookings, + ) as last_7_days_trend_total_billable_bookings, coalesce( 1.0 * sum( case when dd.is_available_for_same_month_projection - then coalesce(mm.created_bookings, 0) + then coalesce(mm.billable_bookings, 0) else 0 end ) / 7, 0 - ) as last_7_days_trend_daily_created_bookings, + ) as last_7_days_trend_daily_billable_bookings, 7 as last_7_days_trend_total_available_days from int_kpis_projected__dimension_dates dd inner join - int_kpis__agg_daily_created_bookings mm + int_kpis__agg_daily_billable_bookings mm on mm.date between dd.previous_6_days and dd.date where is_available_for_last_7_days_projection = true group by 1, 2, 3 @@ -107,24 +107,24 @@ with -- Combination of two sources of trends: same month and last 7 days. coalesce( - smt.same_month_trend_daily_created_bookings, 0 - ) as same_month_trend_daily_created_bookings, + smt.same_month_trend_daily_billable_bookings, 0 + ) as same_month_trend_daily_billable_bookings, coalesce( - l7dt.last_7_days_trend_daily_created_bookings, 0 - ) as last_7_days_trend_daily_created_bookings, + l7dt.last_7_days_trend_daily_billable_bookings, 0 + ) as last_7_days_trend_daily_billable_bookings, round( ( - coalesce(smt.same_month_trend_daily_created_bookings, 0) - + coalesce(l7dt.last_7_days_trend_daily_created_bookings, 0) + coalesce(smt.same_month_trend_daily_billable_bookings, 0) + + coalesce(l7dt.last_7_days_trend_daily_billable_bookings, 0) ) / 2, 0 - ) as projected_daily_created_bookings, + ) as projected_daily_billable_bookings, - -- Total created bookings for the same month and last 7 days + -- Total billable bookings for the same month and last 7 days -- for information purposes - smt.same_month_trend_total_created_bookings, - l7dt.last_7_days_trend_total_created_bookings, + smt.same_month_trend_total_billable_bookings, + l7dt.last_7_days_trend_total_billable_bookings, -- Total available days for the same month and last 7 days -- for information purposes @@ -156,12 +156,12 @@ select -- future. This accounts for all the real historical data. case when not dd.is_in_the_future then 'ACTUAL' else 'PROJECTED' - end as daily_created_bookings_for_reporting_source, + end as daily_billable_bookings_for_reporting_source, case when not dd.is_in_the_future - then coalesce(mm.created_bookings, 0) - else coalesce(cot.projected_daily_created_bookings, 0) - end as daily_created_bookings_for_reporting, + then coalesce(mm.billable_bookings, 0) + else coalesce(cot.projected_daily_billable_bookings, 0) + end as daily_billable_bookings_for_reporting, -- Evaluation source: actual or projected depending on whether the date is -- available for the same month projection. This accounts only for the historical @@ -169,31 +169,31 @@ select -- the performance of the projection. case when dd.is_available_for_same_month_projection then 'ACTUAL' else 'PROJECTED' - end as daily_created_bookings_for_evaluation_source, + end as daily_billable_bookings_for_evaluation_source, case when dd.is_available_for_same_month_projection - then coalesce(mm.created_bookings, 0) - else coalesce(cot.projected_daily_created_bookings, 0) - end as daily_created_bookings_for_evaluation, + then coalesce(mm.billable_bookings, 0) + else coalesce(cot.projected_daily_billable_bookings, 0) + end as daily_billable_bookings_for_evaluation, - -- Specific daily created bookings trends + -- Specific daily billable bookings trends coalesce( - cot.projected_daily_created_bookings, 0 - ) as projected_daily_created_bookings, - coalesce(mm.created_bookings, 0) as actual_daily_created_bookings, + cot.projected_daily_billable_bookings, 0 + ) as projected_daily_billable_bookings, + coalesce(mm.billable_bookings, 0) as actual_daily_billable_bookings, -- For information purposes to debug the trends - cot.same_month_trend_daily_created_bookings, - cot.last_7_days_trend_daily_created_bookings, - cot.same_month_trend_total_created_bookings, - cot.last_7_days_trend_total_created_bookings, + cot.same_month_trend_daily_billable_bookings, + cot.last_7_days_trend_daily_billable_bookings, + cot.same_month_trend_total_billable_bookings, + cot.last_7_days_trend_total_billable_bookings, cot.same_month_trend_total_available_days, cot.last_7_days_trend_total_available_days from int_kpis_projected__dimension_dates dd left join combination_of_trends cot on dd.last_day_month = cot.last_day_month left join - int_kpis__agg_daily_created_bookings mm + int_kpis__agg_daily_billable_bookings mm on dd.date = mm.date and cot.dimension = mm.dimension and cot.dimension_value = mm.dimension_value diff --git a/models/intermediate/kpis/projected/int_kpis_projected__agg_monthly_created_bookings.sql b/models/intermediate/kpis/projected/int_kpis_projected__agg_monthly_billable_bookings.sql similarity index 67% rename from models/intermediate/kpis/projected/int_kpis_projected__agg_monthly_created_bookings.sql rename to models/intermediate/kpis/projected/int_kpis_projected__agg_monthly_billable_bookings.sql index be97ce2..2ea9edf 100644 --- a/models/intermediate/kpis/projected/int_kpis_projected__agg_monthly_created_bookings.sql +++ b/models/intermediate/kpis/projected/int_kpis_projected__agg_monthly_billable_bookings.sql @@ -15,14 +15,14 @@ with -- Metrics -- sum( - daily_created_bookings_for_reporting - ) as current_month_projected_created_bookings, + daily_billable_bookings_for_reporting + ) as current_month_projected_billable_bookings, sum( - daily_created_bookings_for_evaluation - ) as historical_projected_created_bookings, - sum(actual_daily_created_bookings) as actual_created_bookings + daily_billable_bookings_for_evaluation + ) as historical_projected_billable_bookings, + sum(actual_daily_billable_bookings) as actual_billable_bookings - from {{ ref("int_kpis_projected__agg_daily_created_bookings") }} + from {{ ref("int_kpis_projected__agg_daily_billable_bookings") }} group by 1, 2, 3, 4, 5 ), monthly_error_computation as ( @@ -31,22 +31,26 @@ with last_day_month, dimension, dimension_value, - current_month_projected_created_bookings, - historical_projected_created_bookings, - actual_created_bookings, + current_month_projected_billable_bookings, + historical_projected_billable_bookings, + actual_billable_bookings, case when not is_current_month then - abs(historical_projected_created_bookings - actual_created_bookings) + abs( + historical_projected_billable_bookings + - actual_billable_bookings + ) else null end as monthly_absolute_error, case when not is_current_month then 1.0 * abs( - historical_projected_created_bookings - actual_created_bookings + historical_projected_billable_bookings + - actual_billable_bookings ) - / nullif(historical_projected_created_bookings, 0) + / nullif(historical_projected_billable_bookings, 0) else null end as monthly_absolute_percentage_error @@ -73,8 +77,8 @@ select current_month.dimension, current_month.dimension_value, -- Metrics -- - current_month.current_month_projected_created_bookings, - current_month.actual_created_bookings, + current_month.current_month_projected_billable_bookings, + current_month.actual_billable_bookings, -- Error Attribution -- historical_errors.historical_monthly_mean_absolute_error, historical_errors.historical_monthly_mean_absolute_percentage_error diff --git a/models/intermediate/kpis/projected/schema.yml b/models/intermediate/kpis/projected/schema.yml index a7b55c7..8ed2df7 100644 --- a/models/intermediate/kpis/projected/schema.yml +++ b/models/intermediate/kpis/projected/schema.yml @@ -100,15 +100,15 @@ models: data_tests: - not_null - - name: int_kpis_projected__agg_daily_created_bookings + - name: int_kpis_projected__agg_daily_billable_bookings description: | - This model provides the projected daily created bookings. + This model provides the projected daily billable bookings. It considers 2 computations: - - The daily created bookings for the current month, - - The daily created bookings in the past 7 days, + - The daily billable bookings for the current month, + - The daily billable bookings in the past 7 days, and the final value is an arithmetic mean of both. - This model also retrieves the actual created bookings to be able + This model also retrieves the actual billable bookings to be able to compare the projected values with the actual ones. data_tests: @@ -133,7 +133,7 @@ models: data_tests: - assert_dimension_completeness: metric_column_names: - - actual_daily_created_bookings + - actual_daily_billable_bookings - accepted_values: values: - global @@ -193,12 +193,12 @@ models: data_tests: - not_null - - name: daily_created_bookings_for_reporting_source + - name: daily_billable_bookings_for_reporting_source data_type: string description: | - The source of the daily created bookings for reporting. + The source of the daily billable bookings for reporting. This field is used to identify the source of the data displayed - in daily_created_bookings_for_reporting to differentiate between + in daily_billable_bookings_for_reporting to differentiate between the actual and projected values. It's aimed for reforting purposes as any historical month will contain the actual figures. @@ -209,25 +209,25 @@ models: - ACTUAL - PROJECTED - - name: daily_created_bookings_for_reporting + - name: daily_billable_bookings_for_reporting data_type: integer description: | - The daily created bookings for reporting purposes. + The daily billable bookings for reporting purposes. This field contains both the actual and projected values. Any date in the future will contain projected values, while any date in the past will contain actual values. data_tests: - not_null - - name: daily_created_bookings_for_evaluation_source + - name: daily_billable_bookings_for_evaluation_source data_type: string description: | Important: This field is used to evaluate the performance of the projections! - The source of the daily created bookings for evaluation. + The source of the daily billable bookings for evaluation. This field is used to identify the source of the data displayed - in daily_created_bookings_for_evaluation to differentiate between + in daily_billable_bookings_for_evaluation to differentiate between the actual and projected values. It's aimed for evaluation purposes as any historical month can contain projected figures. @@ -239,13 +239,13 @@ models: - ACTUAL - PROJECTED - - name: daily_created_bookings_for_evaluation + - name: daily_billable_bookings_for_evaluation data_type: integer description: | Important: This field is used to evaluate the performance of the projections! - The daily created bookings for evaluation purposes. + The daily billable bookings for evaluation purposes. This field contains both the actual and projected values. Any date in the future will contain projected values. Any date in the past which day is after the yesterday day will also contain @@ -254,56 +254,56 @@ models: data_tests: - not_null - - name: projected_daily_created_bookings + - name: projected_daily_billable_bookings data_type: integer description: | - The projected daily created bookings. This field is the result - of the projection of the daily created bookings for the current month + The projected daily billable bookings. This field is the result + of the projection of the daily billable bookings for the current month and the past 7 days. data_tests: - not_null - - name: actual_daily_created_bookings + - name: actual_daily_billable_bookings description: | - The actual created bookings for the same period as the projected ones. + The actual billable bookings for the same period as the projected ones. This comes from the standard KPIs. data_tests: - not_null - - name: same_month_trend_daily_created_bookings + - name: same_month_trend_daily_billable_bookings data_type: float description: | - The average daily created bookings for the current month. - This field is the result of the division of the actual daily created + The average daily billable bookings for the current month. + This field is the result of the division of the actual daily billable bookings to date by the number of days available within the current month to date, and contains decimals. This is just for information purposes. data_tests: - not_null - - name: last_7_days_trend_daily_created_bookings + - name: last_7_days_trend_daily_billable_bookings data_type: float description: | - The average daily created bookings for the past 7 days. - This field is the result of the division of the actual daily created + The average daily billable bookings for the past 7 days. + This field is the result of the division of the actual daily billable bookings for the past 7 days by 7 days, and contains decimals. This is just for information purposes. data_tests: - not_null - - name: same_month_trend_total_created_bookings + - name: same_month_trend_total_billable_bookings data_type: integer description: | - The total created bookings for the current month. - This field is the result of the sum of the actual daily created + The total billable bookings for the current month. + This field is the result of the sum of the actual daily billable bookings to date. This is just for information purposes. - - name: last_7_days_trend_total_created_bookings + - name: last_7_days_trend_total_billable_bookings data_type: integer description: | - The total created bookings for the past 7 days. - This field is the result of the sum of the actual daily created + The total billable bookings for the past 7 days. + This field is the result of the sum of the actual daily billable bookings for the past 7 days. This is just for information purposes. @@ -323,9 +323,9 @@ models: past 7 days. This is just for information purposes. - - name: int_kpis_projected__agg_monthly_created_bookings + - name: int_kpis_projected__agg_monthly_billable_bookings description: | - This model provides the projected monthly created bookings per dimension + This model provides the projected monthly billable bookings per dimension and dimension value. It only considers the current month. Historical data is considered only to assess the performance of the projections. @@ -359,7 +359,7 @@ models: data_tests: - assert_dimension_completeness: metric_column_names: - - actual_created_bookings + - actual_billable_bookings - accepted_values: values: - global @@ -374,12 +374,12 @@ models: data_tests: - not_null - - name: current_month_projected_created_bookings + - name: current_month_projected_billable_bookings data_type: integer description: | - The projected monthly created bookings for the current month. - This field is the result of the sum of the actual daily created bookings - for the current month to date and the projected daily created bookings + The projected monthly billable bookings for the current month. + This field is the result of the sum of the actual daily billable bookings + for the current month to date and the projected daily billable bookings for the rest of the days in the month that are in the future. The closest we are to the end of the month, the more accurate this value will be. @@ -391,10 +391,10 @@ models: data_tests: - not_null - - name: actual_created_bookings + - name: actual_billable_bookings data_type: integer description: | - The sum of the actual daily created bookings for the current month to date. + The sum of the actual daily billable bookings for the current month to date. This comes from the standard KPIs. data_tests: - not_null @@ -407,7 +407,7 @@ models: This field is used to assess the performance of the projections. This is based on the absolute differences between the projected - monthly created bookings for each previous month vs the actual value. + monthly billable bookings for each previous month vs the actual value. In order to be consistent, it uses the same number of days available for the current month to date as the actual value, and the rest of the days are projected. @@ -425,7 +425,7 @@ models: This field is used to assess the performance of the projections. This is based on the absolute percentage differences between the projected - monthly created bookings for each previous month vs the actual value. + monthly billable bookings for each previous month vs the actual value. In order to be consistent, it uses the same number of days available for the current month to date as the actual value, and the rest of the days are projected. diff --git a/models/intermediate/kpis/schema.yml b/models/intermediate/kpis/schema.yml index b280863..0be83a7 100644 --- a/models/intermediate/kpis/schema.yml +++ b/models/intermediate/kpis/schema.yml @@ -844,10 +844,10 @@ models: Count of accumulated bookings created in a given month up to the given date and per specified dimension that have not been cancelled. - - name: int_kpis__agg_daily_created_bookings + - name: int_kpis__agg_daily_billable_bookings description: | This model computes the dimension aggregation for - Daily Created Bookings. + Daily Billable Bookings. The primary key of this model is end_date, dimension and dimension_value. @@ -874,9 +874,7 @@ models: data_tests: - assert_dimension_completeness: metric_column_names: - - created_bookings - - cancelled_created_bookings - - not_cancelled_created_bookings + - billable_bookings - accepted_values: values: - global @@ -891,24 +889,9 @@ models: data_tests: - not_null - - name: created_bookings + - name: billable_bookings data_type: bigint - description: The daily created bookings for a given date, dimension and value. - - - name: cancelled_created_bookings - data_type: bigint - description: | - The daily cancelled created bookings for a given date, dimension and value. - - - name: not_cancelled_created_bookings - data_type: bigint - description: | - The daily not cancelled created bookings for a given date, dimension and value. - - - name: cancelled_created_bookings_rate - data_type: decimal - description: | - The daily rate of cancelled created bookings for a given date, dimension and value. + description: The daily billable bookings for a given date, dimension and value. - name: int_kpis__agg_monthly_created_bookings description: |