Merged PR 3120: Creation of growth score by deal model for top losers report (intermediate)
# Description Creates a model to identify deal growth based on YoY performance of Created Bookings, YoY performance of Listings Booked in Month and one month shifted YoY performance of Revenue. Also added weighted score to account for revenue size. # 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. - [ ] I have checked for DRY opportunities with other models and docs. **Probably something can be done here, sorry I've not checked.** - [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: #22635
This commit is contained in:
parent
52f01adc11
commit
7f9c038fc0
2 changed files with 667 additions and 0 deletions
|
|
@ -589,3 +589,443 @@ models:
|
|||
description: The value or segment available for the selected dimension.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: int_monthly_growth_score_by_deal
|
||||
description: |
|
||||
The main goal of this model is to provide a growth score by deal and month.
|
||||
The idea behind it is that each deal will have some business performance
|
||||
associated to it over the months, and that comparing how it is currently
|
||||
performing vs. historical data we can determine whether the tendency is to
|
||||
grow or to decay. This is specially useful for AMs to focus their effort
|
||||
towards the clients that have a negative tendency.
|
||||
|
||||
The computation of the growth score is based on 3 main indicators:
|
||||
- Created bookings
|
||||
- Listings booked in month
|
||||
- Total revenue (in gbp)
|
||||
|
||||
The main idea is, for each deal, to compare each of these metrics by
|
||||
checking the latest monthly value vs. the monthly value of the equivalent
|
||||
month on the previous year - in other words, a year-on-year (YoY) comparison.
|
||||
We do this comparison by doing a relative incremental.
|
||||
|
||||
The growth score is computed then by averaging the outcome of the 3 scores.
|
||||
Lastly, in order to provide a prioritisation sense, we have a weighted growth
|
||||
score that results from the multiplication of the growth score per the revenue
|
||||
weight a specific deal has provided in the previous 12 months.
|
||||
|
||||
However, this is not strictly true for Revenue because 1) we have an invoicing
|
||||
delay and 2) in some cases, monthly revenue per deal can be negative. In this
|
||||
specific cases, the YoY comparison is shifted by one month, and an effective
|
||||
revenue value for the revenue share is computed, that cannot be lower than 0.
|
||||
|
||||
In order to keep both a properly set up score and revenue consistency, both
|
||||
a real revenue value and effective revenue value are present in this model,
|
||||
while no MoM or YoY value is computed if negative revenue is found.
|
||||
|
||||
Lastly, this model provides informative date fields, deal attributes, absolute
|
||||
metric values and MoM & YoY relative incrementals to enrich reporting.
|
||||
|
||||
tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
- date
|
||||
- id_deal
|
||||
|
||||
columns:
|
||||
- name: date
|
||||
data_type: date
|
||||
description: |
|
||||
Date corresponding to the last day of the month. Given month
|
||||
metrics are inclusive to this date. Together with id_deal, it
|
||||
acts as the primary key of this model.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: id_deal
|
||||
data_type: string
|
||||
description: |
|
||||
Unique identifier of a Deal. Together with date, it acts as
|
||||
the primary key of this model.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: main_deal_name
|
||||
data_type: string
|
||||
description: |
|
||||
Main name for a Deal, representing the client.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: main_billing_country_iso_3_per_deal
|
||||
data_type: string
|
||||
description: |
|
||||
Main billing country for this client. In some cases
|
||||
it can be null.
|
||||
|
||||
- name: deal_lifecycle_state
|
||||
data_type: string
|
||||
description: |
|
||||
Identifier of the lifecycle state of a given deal
|
||||
in a given month.
|
||||
|
||||
- name: given_month_first_day_month
|
||||
data_type: date
|
||||
description: |
|
||||
Informative field. It indicates the first day of the
|
||||
month corresponding to date.
|
||||
If date = 2024-09-30, this field will be 2024-09-01.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: previous_1_month_first_day_month
|
||||
data_type: date
|
||||
description: |
|
||||
Informative field. It indicates the first day of the
|
||||
previous month with respect to date.
|
||||
If date = 2024-09-30, this field will be 2024-08-01.
|
||||
It can be null if no previous history for that
|
||||
deal is found.
|
||||
|
||||
- name: previous_12_month_first_day_month
|
||||
data_type: date
|
||||
description: |
|
||||
Informative field. It indicates the first day of the
|
||||
month with respect to date, but on the previous year.
|
||||
If date = 2024-09-30, this field will be 2023-09-01.
|
||||
It can be null if no previous history for that
|
||||
deal is found.
|
||||
|
||||
- name: previous_13_month_first_day_month
|
||||
data_type: date
|
||||
description: |
|
||||
Informative field. It indicates the first day of the
|
||||
previous month with respect to date, but on the previous year.
|
||||
If date = 2024-09-30, this field will be 2023-08-01.
|
||||
It can be null if no previous history for that
|
||||
deal is found.
|
||||
|
||||
- name: aggregated_revenue_from_first_day_month
|
||||
data_type: date
|
||||
description: |
|
||||
Informative field. It indicates the first day of the
|
||||
month from the lower bound range in which the revenue
|
||||
aggregation is computed.
|
||||
The aggregation uses the previous 12 months in which we
|
||||
know the revenue, thus:
|
||||
If date = 2024-09-30, this field will be 2023-09-01.
|
||||
It can be null if no previous history for that
|
||||
deal is found.
|
||||
|
||||
- name: aggregated_revenue_to_first_day_month
|
||||
data_type: date
|
||||
description: |
|
||||
Informative field. It indicates the first day of the
|
||||
month from the upper bound range in which the revenue
|
||||
aggregation is computed.
|
||||
The aggregation uses the previous 12 months in which we
|
||||
know the revenue, thus:
|
||||
If date = 2024-09-30, this field will be 2023-08-01.
|
||||
It can be null if no previous history for that
|
||||
deal is found.
|
||||
|
||||
- name: given_month_revenue_in_gbp
|
||||
data_type: decimal
|
||||
description: |
|
||||
Monthly value representing revenue in GBP
|
||||
for a specific deal. This value corresponds to
|
||||
the given month. This value can be negative,
|
||||
but not null.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: previous_1_month_revenue_in_gbp
|
||||
data_type: decimal
|
||||
description: |
|
||||
Monthly value representing revenue in GBP
|
||||
for a specific deal. This value corresponds to
|
||||
the previous month.
|
||||
This value can be negative.
|
||||
This value can be null, thus indicating that no
|
||||
history is available.
|
||||
|
||||
- name: previous_12_month_revenue_in_gbp
|
||||
data_type: decimal
|
||||
description: |
|
||||
Monthly value representing revenue in GBP
|
||||
for a specific deal. This value corresponds to
|
||||
monthly amount generated 12 months ago.
|
||||
This value can be negative.
|
||||
This value can be null, thus indicating that no
|
||||
history is available.
|
||||
|
||||
- name: previous_13_month_revenue_in_gbp
|
||||
data_type: decimal
|
||||
description: |
|
||||
Monthly value representing revenue in GBP
|
||||
for a specific deal. This value corresponds to
|
||||
monthly amount generated 13 months ago.
|
||||
This value can be negative.
|
||||
This value can be null, thus indicating that no
|
||||
history is available.
|
||||
|
||||
- name: mom_revenue_growth
|
||||
data_type: decimal
|
||||
description: |
|
||||
Relative increment of the revenue generated in the
|
||||
current month with respect to the one generated in
|
||||
the previous month.
|
||||
It can be null if any revenue used in the computation
|
||||
is null or it's negative.
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: -1
|
||||
strictly: false
|
||||
|
||||
- name: yoy_revenue_growth
|
||||
data_type: decimal
|
||||
description: |
|
||||
Relative increment of the revenue generated in the
|
||||
current month with respect to the one generated 12
|
||||
months ago.
|
||||
It can be null if any revenue used in the computation
|
||||
is null or it's negative.
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: -1
|
||||
strictly: false
|
||||
|
||||
- name: yoy_1_month_shift_revenue_growth
|
||||
data_type: decimal
|
||||
description: |
|
||||
Relative increment of the revenue generated in the
|
||||
previous month with respect to the one generated 13
|
||||
months ago.
|
||||
It can be null if any revenue used in the computation
|
||||
is null or it's negative.
|
||||
This field is used for the growth score computation.
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: -1
|
||||
strictly: false
|
||||
|
||||
- name: given_month_created_bookings
|
||||
data_type: integer
|
||||
description: |
|
||||
Monthly value representing created bookings
|
||||
for a specific deal. This value corresponds to
|
||||
the given month. This value cannot be null.
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: 0
|
||||
strictly: false
|
||||
|
||||
- name: previous_1_month_created_bookings
|
||||
data_type: integer
|
||||
description: |
|
||||
Monthly value representing created bookings
|
||||
for a specific deal. This value corresponds to
|
||||
the previous month.
|
||||
This value can be null, thus indicating that no
|
||||
history is available.
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: 0
|
||||
strictly: false
|
||||
|
||||
- name: previous_12_month_created_bookings
|
||||
data_type: integer
|
||||
description: |
|
||||
Monthly value representing created bookings
|
||||
for a specific deal. This value corresponds to
|
||||
monthly amount generated 12 months ago.
|
||||
This value can be null, thus indicating that no
|
||||
history is available.
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: 0
|
||||
strictly: false
|
||||
|
||||
- name: mom_created_bookings_growth
|
||||
data_type: decimal
|
||||
description: |
|
||||
Relative increment of the bookings created in the
|
||||
current month with respect to the ones created in
|
||||
the previous month.
|
||||
It can be null if the bookings created in the
|
||||
previous month are null.
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: -1
|
||||
strictly: false
|
||||
|
||||
- name: yoy_created_bookings_growth
|
||||
data_type: decimal
|
||||
description: |
|
||||
Relative increment of the bookings created in the
|
||||
current month with respect to the ones created 12
|
||||
months ago.
|
||||
It can be null if the bookings created 12 months
|
||||
ago are null.
|
||||
This field is used for the growth score computation.
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: -1
|
||||
strictly: false
|
||||
|
||||
- name: given_month_listings_booked_in_month
|
||||
data_type: integer
|
||||
description: |
|
||||
Monthly value representing the listings booked in month
|
||||
for a specific deal. This value corresponds to
|
||||
the given month. This value cannot be null.
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: 0
|
||||
strictly: false
|
||||
|
||||
- name: previous_1_month_listings_booked_in_month
|
||||
data_type: integer
|
||||
description: |
|
||||
Monthly value representing the listings booked in month
|
||||
for a specific deal. This value corresponds to
|
||||
the previous month.
|
||||
This value can be null, thus indicating that no
|
||||
history is available.
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: 0
|
||||
strictly: false
|
||||
|
||||
- name: previous_12_month_listings_booked_in_month
|
||||
data_type: integer
|
||||
description: |
|
||||
Monthly value representing the listings booked in month
|
||||
for a specific deal. This value corresponds to
|
||||
monthly amount generated 12 months ago.
|
||||
This value can be null, thus indicating that no
|
||||
history is available.
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: 0
|
||||
strictly: false
|
||||
|
||||
- name: mom_listings_booked_in_month_growth
|
||||
data_type: decimal
|
||||
description: |
|
||||
Relative increment of the the listings booked in month
|
||||
in the current month with respect to the ones of
|
||||
the previous month.
|
||||
It can be null if the listings booked in month in the
|
||||
previous month are null.
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: -1
|
||||
strictly: false
|
||||
|
||||
- name: yoy_listings_booked_in_month_growth
|
||||
data_type: decimal
|
||||
description: |
|
||||
Relative increment of the listings booked in month
|
||||
in the current month with respect to the ones of 12
|
||||
months ago.
|
||||
It can be null if the listings booked in month of 12
|
||||
months ago are null.
|
||||
This field is used for the growth score computation.
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: -1
|
||||
strictly: false
|
||||
|
||||
- name: deal_revenue_12_months_window
|
||||
data_type: decimal
|
||||
description: |
|
||||
Total aggregated revenue in GBP generated by a deal
|
||||
in the months from the period ranging from the
|
||||
aggregated_revenue_from_first_day_month to
|
||||
aggregated_revenue_to_first_day_month.
|
||||
It can be negative if the sum is negative.
|
||||
It cannot be null.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: effective_deal_revenue_12_months_window
|
||||
data_type: decimal
|
||||
description: |
|
||||
Effective aggregated revenue in GBP generated by a deal
|
||||
in the months from the period ranging from the
|
||||
aggregated_revenue_from_first_day_month to
|
||||
aggregated_revenue_to_first_day_month.
|
||||
All negative monthly revenue values are settled as 0,
|
||||
thus this value should not be reported.
|
||||
It is used for the deal contribution share with respect
|
||||
to the global revenue. It cannot be null.
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: 0
|
||||
strictly: false
|
||||
|
||||
- name: effective_global_revenue_12_months_window
|
||||
data_type: decimal
|
||||
description: |
|
||||
Effective aggregated revenue in GBP generated by all deals
|
||||
in the months from the period ranging from the
|
||||
aggregated_revenue_from_first_day_month to
|
||||
aggregated_revenue_to_first_day_month.
|
||||
All negative monthly revenue values are settled as 0,
|
||||
thus this value should not be reported.
|
||||
It is used for the deal contribution share with respect
|
||||
to the global revenue. It cannot be null.
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: 0
|
||||
strictly: false
|
||||
|
||||
- name: deal_contribution_share_to_global_revenue
|
||||
data_type: decimal
|
||||
description: |
|
||||
Represents the size of the deal in terms of revenue. In
|
||||
other words, what's the percentage of the global revenue
|
||||
that can be attributed to this deal. It cannot be null.
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: 0
|
||||
strictly: false
|
||||
|
||||
- name: deal_contribution_rank_to_global_revenue
|
||||
data_type: integer
|
||||
description: |
|
||||
Represents the ordered list of deals by descending size
|
||||
in terms of revenue. It cannot be null. If more than one
|
||||
deal have the same share, the order is not under control.
|
||||
It cannot be null.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: avg_growth_score
|
||||
data_type: decimal
|
||||
description: |
|
||||
Represents the average score of YoY growth of created
|
||||
bookings, YoY growth of listings booked in month and
|
||||
YoY shifted by one month of revenue.
|
||||
It indicates the tendency of growth of the deal without
|
||||
taking into account its revenue size. It cannot be null.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: weighted_avg_growth_score
|
||||
data_type: decimal
|
||||
description: |
|
||||
It's the weighted version of avg_growth_score that
|
||||
takes into account the client size by using the revenue
|
||||
contribution share of that deal to the global amount.
|
||||
It's the main indicator towards measuring both growth
|
||||
(if positive) or decay (if negative) while weighting
|
||||
the financial impact this deal tendency can have.
|
||||
tests:
|
||||
- not_null
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue