Merged PR 4948: Reporting model for mtd aggregated metrics by deal
# Description Creates a new model for reporting. It includes any relevant metric at Deal level in a similar format as we do for `mtd_aggregated_metrics`. Additionally, there's few Deal attributes - from Hubspot, segmentations, lifecycles, etc. In order to dynamically choose which metrics are relevant on a Deal level, I modified the configuration in `int_mtd_aggregated_metrics` so the extraction is under control. # 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. **Worth discussing the possibilities to include indexes in the future** # Other - [ ] Check if a full-refresh is required after this PR is merged. Related work items: #28998
This commit is contained in:
parent
ca5db795a3
commit
a67e3f46ba
5 changed files with 558 additions and 1 deletions
|
|
@ -8,6 +8,7 @@
|
|||
"number_format": "integer",
|
||||
"increment_sign_format": "positive",
|
||||
"display_exclusion": "NONE",
|
||||
"include_in_account_reporting": true,
|
||||
},
|
||||
{
|
||||
"order_by": 2,
|
||||
|
|
@ -18,6 +19,7 @@
|
|||
"number_format": "integer",
|
||||
"increment_sign_format": "positive",
|
||||
"display_exclusion": "NONE",
|
||||
"include_in_account_reporting": true,
|
||||
},
|
||||
{
|
||||
"order_by": 3,
|
||||
|
|
@ -28,6 +30,7 @@
|
|||
"number_format": "integer",
|
||||
"increment_sign_format": "positive",
|
||||
"display_exclusion": "NONE",
|
||||
"include_in_account_reporting": true,
|
||||
},
|
||||
{
|
||||
"order_by": 4,
|
||||
|
|
@ -38,6 +41,7 @@
|
|||
"number_format": "integer",
|
||||
"increment_sign_format": "positive",
|
||||
"display_exclusion": "NONE",
|
||||
"include_in_account_reporting": true,
|
||||
},
|
||||
{
|
||||
"order_by": 5,
|
||||
|
|
@ -48,6 +52,7 @@
|
|||
"number_format": "integer",
|
||||
"increment_sign_format": "positive",
|
||||
"display_exclusion": "NONE",
|
||||
"include_in_account_reporting": true,
|
||||
},
|
||||
{
|
||||
"order_by": 6,
|
||||
|
|
@ -58,6 +63,7 @@
|
|||
"number_format": "integer",
|
||||
"increment_sign_format": "negative",
|
||||
"display_exclusion": "NONE",
|
||||
"include_in_account_reporting": true,
|
||||
},
|
||||
{
|
||||
"order_by": 7,
|
||||
|
|
@ -68,6 +74,7 @@
|
|||
"number_format": "integer",
|
||||
"increment_sign_format": "positive",
|
||||
"display_exclusion": "NONE",
|
||||
"include_in_account_reporting": true,
|
||||
},
|
||||
{
|
||||
"order_by": 8,
|
||||
|
|
@ -78,6 +85,7 @@
|
|||
"number_format": "integer",
|
||||
"increment_sign_format": "negative",
|
||||
"display_exclusion": "NONE",
|
||||
"include_in_account_reporting": true,
|
||||
},
|
||||
{
|
||||
"order_by": 10,
|
||||
|
|
@ -88,6 +96,7 @@
|
|||
"number_format": "integer",
|
||||
"increment_sign_format": "positive",
|
||||
"display_exclusion": "NONE",
|
||||
"include_in_account_reporting": true,
|
||||
},
|
||||
{
|
||||
"order_by": 11,
|
||||
|
|
@ -98,6 +107,7 @@
|
|||
"number_format": "integer",
|
||||
"increment_sign_format": "positive",
|
||||
"display_exclusion": "NONE",
|
||||
"include_in_account_reporting": true,
|
||||
},
|
||||
{
|
||||
"order_by": 12,
|
||||
|
|
@ -108,6 +118,7 @@
|
|||
"number_format": "integer",
|
||||
"increment_sign_format": "positive",
|
||||
"display_exclusion": "NONE",
|
||||
"include_in_account_reporting": true,
|
||||
},
|
||||
{
|
||||
"order_by": 13,
|
||||
|
|
@ -118,6 +129,7 @@
|
|||
"number_format": "integer",
|
||||
"increment_sign_format": "positive",
|
||||
"display_exclusion": "NONE",
|
||||
"include_in_account_reporting": true,
|
||||
},
|
||||
{
|
||||
"order_by": 20,
|
||||
|
|
@ -128,6 +140,7 @@
|
|||
"number_format": "integer",
|
||||
"increment_sign_format": "positive",
|
||||
"display_exclusion": "NONE",
|
||||
"include_in_account_reporting": false,
|
||||
},
|
||||
{
|
||||
"order_by": 21,
|
||||
|
|
@ -138,6 +151,7 @@
|
|||
"number_format": "integer",
|
||||
"increment_sign_format": "positive",
|
||||
"display_exclusion": "NONE",
|
||||
"include_in_account_reporting": false,
|
||||
},
|
||||
{
|
||||
"order_by": 22,
|
||||
|
|
@ -148,6 +162,7 @@
|
|||
"number_format": "integer",
|
||||
"increment_sign_format": "positive",
|
||||
"display_exclusion": "NONE",
|
||||
"include_in_account_reporting": false,
|
||||
},
|
||||
{
|
||||
"order_by": 23,
|
||||
|
|
@ -158,6 +173,7 @@
|
|||
"number_format": "integer",
|
||||
"increment_sign_format": "positive",
|
||||
"display_exclusion": "NONE",
|
||||
"include_in_account_reporting": false,
|
||||
},
|
||||
{
|
||||
"order_by": 24,
|
||||
|
|
@ -168,6 +184,7 @@
|
|||
"number_format": "integer",
|
||||
"increment_sign_format": "positive",
|
||||
"display_exclusion": "NONE",
|
||||
"include_in_account_reporting": false,
|
||||
},
|
||||
{
|
||||
"order_by": 25,
|
||||
|
|
@ -178,6 +195,7 @@
|
|||
"number_format": "integer",
|
||||
"increment_sign_format": "negative",
|
||||
"display_exclusion": "NONE",
|
||||
"include_in_account_reporting": false,
|
||||
},
|
||||
{
|
||||
"order_by": 30,
|
||||
|
|
@ -188,6 +206,7 @@
|
|||
"number_format": "integer",
|
||||
"increment_sign_format": "positive",
|
||||
"display_exclusion": "NONE",
|
||||
"include_in_account_reporting": true,
|
||||
},
|
||||
{
|
||||
"order_by": 31,
|
||||
|
|
@ -198,6 +217,7 @@
|
|||
"number_format": "integer",
|
||||
"increment_sign_format": "positive",
|
||||
"display_exclusion": "NONE",
|
||||
"include_in_account_reporting": true,
|
||||
},
|
||||
{
|
||||
"order_by": 32,
|
||||
|
|
@ -208,6 +228,7 @@
|
|||
"number_format": "integer",
|
||||
"increment_sign_format": "positive",
|
||||
"display_exclusion": "NONE",
|
||||
"include_in_account_reporting": true,
|
||||
},
|
||||
{
|
||||
"order_by": 33,
|
||||
|
|
@ -218,6 +239,7 @@
|
|||
"number_format": "integer",
|
||||
"increment_sign_format": "positive",
|
||||
"display_exclusion": "NONE",
|
||||
"include_in_account_reporting": true,
|
||||
},
|
||||
{
|
||||
"order_by": 34,
|
||||
|
|
@ -228,6 +250,7 @@
|
|||
"number_format": "integer",
|
||||
"increment_sign_format": "positive",
|
||||
"display_exclusion": "NONE",
|
||||
"include_in_account_reporting": true,
|
||||
},
|
||||
{
|
||||
"order_by": 35,
|
||||
|
|
@ -238,6 +261,7 @@
|
|||
"number_format": "integer",
|
||||
"increment_sign_format": "negative",
|
||||
"display_exclusion": "NONE",
|
||||
"include_in_account_reporting": true,
|
||||
},
|
||||
{
|
||||
"order_by": 40,
|
||||
|
|
@ -248,6 +272,7 @@
|
|||
"number_format": "integer",
|
||||
"increment_sign_format": "negative",
|
||||
"display_exclusion": "NONE",
|
||||
"include_in_account_reporting": true,
|
||||
},
|
||||
{
|
||||
"order_by": 100,
|
||||
|
|
@ -258,6 +283,7 @@
|
|||
"number_format": "percentage",
|
||||
"increment_sign_format": "positive",
|
||||
"display_exclusion": "INVOICING",
|
||||
"include_in_account_reporting": true,
|
||||
},
|
||||
{
|
||||
"order_by": 101,
|
||||
|
|
@ -268,6 +294,7 @@
|
|||
"number_format": "percentage",
|
||||
"increment_sign_format": "positive",
|
||||
"display_exclusion": "INVOICING",
|
||||
"include_in_account_reporting": true,
|
||||
},
|
||||
{
|
||||
"order_by": 102,
|
||||
|
|
@ -278,6 +305,7 @@
|
|||
"number_format": "percentage",
|
||||
"increment_sign_format": "negative",
|
||||
"display_exclusion": "NONE",
|
||||
"include_in_account_reporting": true,
|
||||
},
|
||||
{
|
||||
"order_by": 110,
|
||||
|
|
@ -288,6 +316,7 @@
|
|||
"number_format": "percentage",
|
||||
"increment_sign_format": "negative",
|
||||
"display_exclusion": "NONE",
|
||||
"include_in_account_reporting": true,
|
||||
},
|
||||
{
|
||||
"order_by": 111,
|
||||
|
|
@ -298,6 +327,7 @@
|
|||
"number_format": "percentage",
|
||||
"increment_sign_format": "negative",
|
||||
"display_exclusion": "NONE",
|
||||
"include_in_account_reporting": true,
|
||||
},
|
||||
{
|
||||
"order_by": 120,
|
||||
|
|
@ -308,6 +338,7 @@
|
|||
"number_format": "percentage",
|
||||
"increment_sign_format": "positive",
|
||||
"display_exclusion": "NONE",
|
||||
"include_in_account_reporting": true,
|
||||
},
|
||||
{
|
||||
"order_by": 121,
|
||||
|
|
@ -318,6 +349,7 @@
|
|||
"number_format": "percentage",
|
||||
"increment_sign_format": "positive",
|
||||
"display_exclusion": "NONE",
|
||||
"include_in_account_reporting": true,
|
||||
},
|
||||
{
|
||||
"order_by": 122,
|
||||
|
|
@ -328,6 +360,7 @@
|
|||
"number_format": "percentage",
|
||||
"increment_sign_format": "negative",
|
||||
"display_exclusion": "NONE",
|
||||
"include_in_account_reporting": true,
|
||||
},
|
||||
{
|
||||
"order_by": 123,
|
||||
|
|
@ -338,6 +371,7 @@
|
|||
"number_format": "percentage",
|
||||
"increment_sign_format": "positive",
|
||||
"display_exclusion": "NONE",
|
||||
"include_in_account_reporting": true,
|
||||
},
|
||||
{
|
||||
"order_by": 130,
|
||||
|
|
@ -348,6 +382,7 @@
|
|||
"number_format": "percentage",
|
||||
"increment_sign_format": "negative",
|
||||
"display_exclusion": "ONGOING_MONTH",
|
||||
"include_in_account_reporting": false,
|
||||
},
|
||||
{
|
||||
"order_by": 131,
|
||||
|
|
@ -358,6 +393,7 @@
|
|||
"number_format": "percentage",
|
||||
"increment_sign_format": "negative",
|
||||
"display_exclusion": "ONGOING_MONTH",
|
||||
"include_in_account_reporting": false,
|
||||
},
|
||||
{
|
||||
"order_by": 132,
|
||||
|
|
@ -368,6 +404,7 @@
|
|||
"number_format": "percentage",
|
||||
"increment_sign_format": "negative",
|
||||
"display_exclusion": "ONGOING_MONTH",
|
||||
"include_in_account_reporting": false,
|
||||
},
|
||||
{
|
||||
"order_by": 200,
|
||||
|
|
@ -378,6 +415,7 @@
|
|||
"number_format": "currency_gbp",
|
||||
"increment_sign_format": "positive",
|
||||
"display_exclusion": "INVOICING",
|
||||
"include_in_account_reporting": true,
|
||||
},
|
||||
{
|
||||
"order_by": 201,
|
||||
|
|
@ -388,6 +426,7 @@
|
|||
"number_format": "currency_gbp",
|
||||
"increment_sign_format": "positive",
|
||||
"display_exclusion": "INVOICING",
|
||||
"include_in_account_reporting": true,
|
||||
},
|
||||
{
|
||||
"order_by": 202,
|
||||
|
|
@ -398,6 +437,7 @@
|
|||
"number_format": "currency_gbp",
|
||||
"increment_sign_format": "positive",
|
||||
"display_exclusion": "INVOICING",
|
||||
"include_in_account_reporting": true,
|
||||
},
|
||||
{
|
||||
"order_by": 203,
|
||||
|
|
@ -408,6 +448,7 @@
|
|||
"number_format": "currency_gbp",
|
||||
"increment_sign_format": "positive",
|
||||
"display_exclusion": "ONGOING_MONTH",
|
||||
"include_in_account_reporting": false,
|
||||
},
|
||||
{
|
||||
"order_by": 204,
|
||||
|
|
@ -418,6 +459,7 @@
|
|||
"number_format": "currency_gbp",
|
||||
"increment_sign_format": "positive",
|
||||
"display_exclusion": "ONGOING_MONTH",
|
||||
"include_in_account_reporting": false,
|
||||
},
|
||||
{
|
||||
"order_by": 211,
|
||||
|
|
@ -428,6 +470,7 @@
|
|||
"number_format": "converted_metric_currency_gbp",
|
||||
"increment_sign_format": "positive",
|
||||
"display_exclusion": "INVOICING",
|
||||
"include_in_account_reporting": true,
|
||||
},
|
||||
{
|
||||
"order_by": 212,
|
||||
|
|
@ -438,6 +481,7 @@
|
|||
"number_format": "converted_metric_currency_gbp",
|
||||
"increment_sign_format": "positive",
|
||||
"display_exclusion": "INVOICING",
|
||||
"include_in_account_reporting": true,
|
||||
},
|
||||
{
|
||||
"order_by": 213,
|
||||
|
|
@ -448,6 +492,7 @@
|
|||
"number_format": "converted_metric_currency_gbp",
|
||||
"increment_sign_format": "positive",
|
||||
"display_exclusion": "INVOICING",
|
||||
"include_in_account_reporting": false,
|
||||
},
|
||||
{
|
||||
"order_by": 214,
|
||||
|
|
@ -458,6 +503,7 @@
|
|||
"number_format": "converted_metric_currency_gbp",
|
||||
"increment_sign_format": "positive",
|
||||
"display_exclusion": "INVOICING",
|
||||
"include_in_account_reporting": true,
|
||||
},
|
||||
{
|
||||
"order_by": 220,
|
||||
|
|
@ -468,6 +514,7 @@
|
|||
"number_format": "currency_gbp",
|
||||
"increment_sign_format": "positive",
|
||||
"display_exclusion": "INVOICING",
|
||||
"include_in_account_reporting": true,
|
||||
},
|
||||
{
|
||||
"order_by": 224,
|
||||
|
|
@ -478,6 +525,7 @@
|
|||
"number_format": "currency_gbp",
|
||||
"increment_sign_format": "positive",
|
||||
"display_exclusion": "INVOICING",
|
||||
"include_in_account_reporting": true,
|
||||
},
|
||||
{
|
||||
"order_by": 225,
|
||||
|
|
@ -488,6 +536,7 @@
|
|||
"number_format": "currency_gbp",
|
||||
"increment_sign_format": "positive",
|
||||
"display_exclusion": "INVOICING",
|
||||
"include_in_account_reporting": true,
|
||||
},
|
||||
{
|
||||
"order_by": 226,
|
||||
|
|
@ -498,6 +547,7 @@
|
|||
"number_format": "currency_gbp",
|
||||
"increment_sign_format": "positive",
|
||||
"display_exclusion": "INVOICING",
|
||||
"include_in_account_reporting": true,
|
||||
},
|
||||
{
|
||||
"order_by": 227,
|
||||
|
|
@ -508,6 +558,7 @@
|
|||
"number_format": "currency_gbp",
|
||||
"increment_sign_format": "positive",
|
||||
"display_exclusion": "INVOICING",
|
||||
"include_in_account_reporting": true,
|
||||
},
|
||||
{
|
||||
"order_by": 231,
|
||||
|
|
@ -518,6 +569,7 @@
|
|||
"number_format": "currency_gbp",
|
||||
"increment_sign_format": "positive",
|
||||
"display_exclusion": "INVOICING",
|
||||
"include_in_account_reporting": true,
|
||||
},
|
||||
{
|
||||
"order_by": 232,
|
||||
|
|
@ -528,6 +580,7 @@
|
|||
"number_format": "currency_gbp",
|
||||
"increment_sign_format": "positive",
|
||||
"display_exclusion": "INVOICING",
|
||||
"include_in_account_reporting": true,
|
||||
},
|
||||
{
|
||||
"order_by": 233,
|
||||
|
|
@ -538,6 +591,7 @@
|
|||
"number_format": "currency_gbp",
|
||||
"increment_sign_format": "positive",
|
||||
"display_exclusion": "INVOICING",
|
||||
"include_in_account_reporting": true,
|
||||
},
|
||||
{
|
||||
"order_by": 234,
|
||||
|
|
@ -548,6 +602,7 @@
|
|||
"number_format": "currency_gbp",
|
||||
"increment_sign_format": "positive",
|
||||
"display_exclusion": "INVOICING",
|
||||
"include_in_account_reporting": true,
|
||||
},
|
||||
{
|
||||
"order_by": 235,
|
||||
|
|
@ -558,6 +613,7 @@
|
|||
"number_format": "currency_gbp",
|
||||
"increment_sign_format": "positive",
|
||||
"display_exclusion": "INVOICING",
|
||||
"include_in_account_reporting": true,
|
||||
},
|
||||
{
|
||||
"order_by": 236,
|
||||
|
|
@ -568,6 +624,7 @@
|
|||
"number_format": "currency_gbp",
|
||||
"increment_sign_format": "positive",
|
||||
"display_exclusion": "INVOICING",
|
||||
"include_in_account_reporting": true,
|
||||
},
|
||||
{
|
||||
"order_by": 237,
|
||||
|
|
@ -578,6 +635,7 @@
|
|||
"number_format": "currency_gbp",
|
||||
"increment_sign_format": "positive",
|
||||
"display_exclusion": "INVOICING",
|
||||
"include_in_account_reporting": true,
|
||||
},
|
||||
{
|
||||
"order_by": 240,
|
||||
|
|
@ -588,6 +646,7 @@
|
|||
"number_format": "currency_gbp",
|
||||
"increment_sign_format": "positive",
|
||||
"display_exclusion": "INVOICING",
|
||||
"include_in_account_reporting": true,
|
||||
},
|
||||
{
|
||||
"order_by": 245,
|
||||
|
|
@ -598,6 +657,7 @@
|
|||
"number_format": "currency_gbp",
|
||||
"increment_sign_format": "positive",
|
||||
"display_exclusion": "INVOICING",
|
||||
"include_in_account_reporting": false,
|
||||
},
|
||||
{
|
||||
"order_by": 246,
|
||||
|
|
@ -608,6 +668,7 @@
|
|||
"number_format": "currency_gbp",
|
||||
"increment_sign_format": "positive",
|
||||
"display_exclusion": "INVOICING",
|
||||
"include_in_account_reporting": false,
|
||||
},
|
||||
{
|
||||
"order_by": 250,
|
||||
|
|
@ -618,6 +679,7 @@
|
|||
"number_format": "currency_gbp",
|
||||
"increment_sign_format": "positive",
|
||||
"display_exclusion": "NONE",
|
||||
"include_in_account_reporting": true,
|
||||
},
|
||||
{
|
||||
"order_by": 251,
|
||||
|
|
@ -628,6 +690,7 @@
|
|||
"number_format": "converted_metric_currency_gbp",
|
||||
"increment_sign_format": "positive",
|
||||
"display_exclusion": "NONE",
|
||||
"include_in_account_reporting": true,
|
||||
},
|
||||
{
|
||||
"order_by": 252,
|
||||
|
|
@ -638,6 +701,7 @@
|
|||
"number_format": "converted_metric_currency_gbp",
|
||||
"increment_sign_format": "positive",
|
||||
"display_exclusion": "NONE",
|
||||
"include_in_account_reporting": true,
|
||||
},
|
||||
{
|
||||
"order_by": 260,
|
||||
|
|
@ -648,6 +712,7 @@
|
|||
"number_format": "currency_gbp",
|
||||
"increment_sign_format": "positive",
|
||||
"display_exclusion": "NONE",
|
||||
"include_in_account_reporting": true,
|
||||
},
|
||||
{
|
||||
"order_by": 262,
|
||||
|
|
@ -658,6 +723,7 @@
|
|||
"number_format": "currency_gbp",
|
||||
"increment_sign_format": "positive",
|
||||
"display_exclusion": "NONE",
|
||||
"include_in_account_reporting": true,
|
||||
},
|
||||
{
|
||||
"order_by": 263,
|
||||
|
|
@ -668,6 +734,7 @@
|
|||
"number_format": "currency_gbp",
|
||||
"increment_sign_format": "negative",
|
||||
"display_exclusion": "INVOICING",
|
||||
"include_in_account_reporting": true,
|
||||
},
|
||||
{
|
||||
"order_by": 264,
|
||||
|
|
@ -678,6 +745,7 @@
|
|||
"number_format": "currency_gbp",
|
||||
"increment_sign_format": "positive",
|
||||
"display_exclusion": "INVOICING",
|
||||
"include_in_account_reporting": true,
|
||||
},
|
||||
{
|
||||
"order_by": 265,
|
||||
|
|
@ -688,6 +756,7 @@
|
|||
"number_format": "currency_gbp",
|
||||
"increment_sign_format": "positive",
|
||||
"display_exclusion": "NONE",
|
||||
"include_in_account_reporting": true,
|
||||
},
|
||||
{
|
||||
"order_by": 270,
|
||||
|
|
@ -698,6 +767,7 @@
|
|||
"number_format": "currency_gbp",
|
||||
"increment_sign_format": "negative",
|
||||
"display_exclusion": "NONE",
|
||||
"include_in_account_reporting": true,
|
||||
},
|
||||
{
|
||||
"order_by": 271,
|
||||
|
|
@ -708,6 +778,7 @@
|
|||
"number_format": "currency_gbp",
|
||||
"increment_sign_format": "negative",
|
||||
"display_exclusion": "NONE",
|
||||
"include_in_account_reporting": true,
|
||||
},
|
||||
] %}
|
||||
with
|
||||
|
|
@ -728,6 +799,7 @@ with
|
|||
dimension_value,
|
||||
previous_year_date,
|
||||
{{ metric.order_by }} as order_by,
|
||||
{{ metric.include_in_account_reporting }} as include_in_account_reporting,
|
||||
-- quotation marks added because text format
|
||||
'{{ metric.number_format }}' as number_format,
|
||||
'{{ metric.display_exclusion }}' as display_exclusion,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,77 @@
|
|||
with
|
||||
int_mtd_aggregated_metrics as (
|
||||
select *
|
||||
from {{ ref("int_mtd_aggregated_metrics") }} m
|
||||
where dimension = 'by_deal' and include_in_account_reporting = true
|
||||
),
|
||||
int_kpis__dimension_deals as (select * from {{ ref("int_kpis__dimension_deals") }}),
|
||||
int_hubspot__deal as (select * from {{ ref("int_hubspot__deal") }}),
|
||||
daily_deal_lifecycle as (select * from {{ ref("int_kpis__lifecycle_daily_deal") }}),
|
||||
int_kpis__dimension_daily_accommodation as (
|
||||
select * from {{ ref("int_kpis__dimension_daily_accommodation") }}
|
||||
)
|
||||
|
||||
select
|
||||
-- PRIMARY KEY --
|
||||
m.date,
|
||||
m.dimension_value as id_deal,
|
||||
m.metric,
|
||||
|
||||
-- TIME ATTRIBUTES --
|
||||
m.year,
|
||||
m.month,
|
||||
m.day,
|
||||
m.is_end_of_month,
|
||||
m.is_current_month,
|
||||
m.is_end_of_month_or_yesterday,
|
||||
m.first_day_month,
|
||||
|
||||
-- MAIN DEAL ATTRIBUTES --
|
||||
m.dimension_value || '-' || coalesce(ikdd.main_deal_name, '') as deal,
|
||||
coalesce(
|
||||
dda.active_accommodations_per_deal_segmentation, 'UNSET'
|
||||
) as active_accommodations_per_deal_segmentation,
|
||||
ikdd.main_billing_country_iso_3_per_deal,
|
||||
|
||||
-- HUBSPOT ATTRIBUTES --
|
||||
hd.account_manager,
|
||||
|
||||
-- DEAL BUSINESS SCOPE
|
||||
case
|
||||
when ikdd.client_type = 'API'
|
||||
then 'API'
|
||||
when ikdd.client_type = 'PLATFORM'
|
||||
then
|
||||
case
|
||||
when
|
||||
ikdd.id_deal is not null
|
||||
and m.date >= ikdd.min_user_in_new_dash_since_date_utc
|
||||
then 'New Dash'
|
||||
else 'Old Dash'
|
||||
end
|
||||
else 'UNSET'
|
||||
end as business_scope,
|
||||
|
||||
-- DEAL LIFECYCLE --
|
||||
daily_deal_lifecycle.deal_lifecycle_state,
|
||||
|
||||
-- METRIC VALUES AND DISPLAY --
|
||||
m.order_by,
|
||||
m.number_format,
|
||||
-- Force 0 if null to avoid nulls in the report
|
||||
coalesce(m.value, 0) as value,
|
||||
coalesce(m.previous_year_value, 0) as previous_year_value,
|
||||
m.relative_increment,
|
||||
m.relative_increment_with_sign_format,
|
||||
m.display_exclusion
|
||||
from int_mtd_aggregated_metrics m
|
||||
left join int_kpis__dimension_deals ikdd on m.dimension_value = ikdd.id_deal
|
||||
left join int_hubspot__deal hd on m.dimension_value = hd.id_deal
|
||||
left join
|
||||
daily_deal_lifecycle
|
||||
on m.date = daily_deal_lifecycle.date
|
||||
and m.dimension_value = daily_deal_lifecycle.id_deal
|
||||
left join
|
||||
int_kpis__dimension_daily_accommodation as dda
|
||||
on m.date = dda.date
|
||||
and m.dimension_value = dda.id_deal
|
||||
|
|
@ -283,6 +283,14 @@ models:
|
|||
order for displaying purposes. Null values are accepted, but keep
|
||||
in mind that then there's no default controlled display order.
|
||||
|
||||
- name: include_in_account_reporting
|
||||
data_type: boolean
|
||||
description: |
|
||||
Category to indicate if the metric should be included in the account
|
||||
reporting (by deal). This will limit the display for reporting purposes.
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: display_exclusion
|
||||
data_type: string
|
||||
description: |
|
||||
|
|
@ -2602,3 +2610,154 @@ models:
|
|||
Relative difference between the current year YTD and the YTD target,
|
||||
with a sign to represent if the relative difference is good (positive) or bad
|
||||
(negative) for our business.
|
||||
|
||||
- name: int_mtd_aggregated_metrics_by_deal
|
||||
description: |
|
||||
This model aggregates the historic information of our business by providing
|
||||
different metrics at account level (by id_deal).
|
||||
Additionally it provides Deal attributes.
|
||||
|
||||
data_tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
- date
|
||||
- metric
|
||||
- id_deal
|
||||
columns:
|
||||
- name: year
|
||||
data_type: int
|
||||
description: Year number of the given date.
|
||||
|
||||
- name: month
|
||||
data_type: int
|
||||
description: Month number of the given date.
|
||||
|
||||
- name: day
|
||||
data_type: int
|
||||
description: Day monthly number of the given date.
|
||||
|
||||
- name: is_end_of_month
|
||||
data_type: boolean
|
||||
description: Is end of month, 1 for yes, 0 for no.
|
||||
|
||||
- name: is_current_month
|
||||
data_type: boolean
|
||||
description: |
|
||||
Checks if the date is within the current executed month,
|
||||
1 for yes, 0 for no.
|
||||
|
||||
- name: is_end_of_month_or_yesterday
|
||||
data_type: boolean
|
||||
description: |
|
||||
Checks if the date is end of month or yesterday,
|
||||
1 for yes, 0 for no.
|
||||
|
||||
- name: first_day_month
|
||||
data_type: date
|
||||
description: |
|
||||
First day of the month corresponding to the date field.
|
||||
It comes from int_dates_mtd logic.
|
||||
|
||||
- name: date
|
||||
data_type: date
|
||||
description: |
|
||||
Main date for the computation, that is used for filters.
|
||||
It comes from int_dates_mtd logic.
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: id_deal
|
||||
data_type: string
|
||||
description: |
|
||||
Unique ID for a deal, or account.
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: deal
|
||||
data_type: string
|
||||
description: |
|
||||
Combination of the ID and the Name of the deal.
|
||||
|
||||
- name: active_accommodations_per_deal_segmentation
|
||||
data_type: string
|
||||
description: |
|
||||
Segment value based on the number of listings booked in 12 months
|
||||
for a given deal and date.
|
||||
|
||||
- name: main_billing_country_iso_3_per_deal
|
||||
data_type: string
|
||||
description: |
|
||||
ISO 3166-1 alpha-3 main country code in which the Deal is billed.
|
||||
In some cases it's null.
|
||||
|
||||
- name: business_scope
|
||||
data_type: string
|
||||
description: |
|
||||
Business scope identifying the metric source.
|
||||
|
||||
- name: account_manager
|
||||
data_type: string
|
||||
description: |
|
||||
Account manager of the deal.
|
||||
In some cases it's null.
|
||||
|
||||
- name: deal_lifecycle_state
|
||||
data_type: string
|
||||
description: |
|
||||
Lifecycle state of the deal.
|
||||
|
||||
- name: metric
|
||||
data_type: text
|
||||
description: Name of the business metric.
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: order_by
|
||||
data_type: integer
|
||||
description: |
|
||||
Order for displaying purposes. Null values are accepted, but keep
|
||||
in mind that then there's no default controlled display order.
|
||||
|
||||
- name: number_format
|
||||
data_type: text
|
||||
description: Allows for grouping and formatting for displaying purposes.
|
||||
|
||||
- name: value
|
||||
data_type: numeric
|
||||
description: |
|
||||
Numeric value (integer or decimal) that corresponds to the MTD computation of the metric
|
||||
at a given date. Note that if the month is not in progress, then this value corresponds
|
||||
to the monthly figure.
|
||||
|
||||
- name: previous_year_value
|
||||
data_type: numeric
|
||||
description: |
|
||||
Numeric value (integer or decimal) that corresponds to the MTD computation of the metric
|
||||
on the previous year at a given date.
|
||||
|
||||
- name: relative_increment
|
||||
data_type: numeric
|
||||
description: |
|
||||
Numeric value that corresponds to the relative increment between value and previous year value,
|
||||
following the computation: value / previous_year_value - 1.
|
||||
|
||||
- name: relative_increment_with_sign_format
|
||||
data_type: numeric
|
||||
description: |
|
||||
Relative_increment value multiplied by -1 in case this metric's growth doesn't have a
|
||||
positive impact for Truvi, otherwise is equal to relative_increment.
|
||||
This value is specially created for formatting in PBI
|
||||
|
||||
- name: display_exclusion
|
||||
data_type: string
|
||||
description: |
|
||||
Category to indicate if the metric requires a certain exclusion due
|
||||
to relying on not timely information.
|
||||
This will limit the display for reporting purposes.
|
||||
data_tests:
|
||||
- not_null
|
||||
- accepted_values:
|
||||
values:
|
||||
- NONE
|
||||
- INVOICING
|
||||
- ONGOING_MONTH
|
||||
|
|
|
|||
64
models/reporting/general/mtd_aggregated_metrics_by_deal.sql
Normal file
64
models/reporting/general/mtd_aggregated_metrics_by_deal.sql
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
with
|
||||
int_mtd_aggregated_metrics_by_deal as (
|
||||
select * from {{ ref("int_mtd_aggregated_metrics_by_deal") }}
|
||||
)
|
||||
|
||||
select
|
||||
-- PRIMARY KEY --
|
||||
m.date as date,
|
||||
m.id_deal as id_deal,
|
||||
m.metric as metric,
|
||||
|
||||
-- TIME ATTRIBUTES --
|
||||
m.year as year,
|
||||
m.month as month,
|
||||
m.day as day,
|
||||
case when m.is_end_of_month then 1 else 0 end as is_end_of_month,
|
||||
case when m.is_current_month then 1 else 0 end as is_current_month,
|
||||
case
|
||||
when m.is_end_of_month_or_yesterday then 1 else 0
|
||||
end as is_end_of_month_or_yesterday,
|
||||
m.first_day_month as first_day_month,
|
||||
|
||||
-- MAIN DEAL ATTRIBUTES --
|
||||
m.deal as deal,
|
||||
m.active_accommodations_per_deal_segmentation
|
||||
as active_accommodations_per_deal_segmentation,
|
||||
m.main_billing_country_iso_3_per_deal as main_billing_country_iso_3_per_deal,
|
||||
|
||||
-- HUBSPOT ATTRIBUTES --
|
||||
m.account_manager as account_manager,
|
||||
|
||||
-- DEAL BUSINESS SCOPE
|
||||
m.business_scope as business_scope,
|
||||
|
||||
-- DEAL LIFECYCLE --
|
||||
m.deal_lifecycle_state as deal_lifecycle_state,
|
||||
|
||||
-- METRIC VALUES AND DISPLAY --
|
||||
m.order_by as order_by,
|
||||
m.number_format as number_format,
|
||||
m.value as value,
|
||||
m.previous_year_value as previous_year_value,
|
||||
m.relative_increment as relative_increment,
|
||||
m.relative_increment_with_sign_format as relative_increment_with_sign_format
|
||||
from int_mtd_aggregated_metrics_by_deal m
|
||||
where
|
||||
(
|
||||
(
|
||||
-- Not show current + previous month if the metric depends on
|
||||
-- invoicing cycle and it is before the 20th of the month, if it
|
||||
-- is the 20th of the month or after, only exclude the current
|
||||
-- month.
|
||||
m.display_exclusion = 'INVOICING'
|
||||
and {{ is_date_before_20th_of_previous_month("m.date") }}
|
||||
)
|
||||
or (
|
||||
-- Handle exclusion for Churn/MRR metrics: do not show them in the
|
||||
-- current month.
|
||||
m.display_exclusion = 'ONGOING_MONTH'
|
||||
and date_trunc('month', m.date) < date_trunc('month', current_date)
|
||||
)
|
||||
-- Keep all history for the rest of metrics
|
||||
or m.display_exclusion = 'NONE'
|
||||
)
|
||||
|
|
@ -455,7 +455,7 @@ models:
|
|||
data_type: numeric
|
||||
description: |
|
||||
Relative_increment value multiplied by -1 in case this metric's growth doesn't have a
|
||||
positive impact for Superhog, otherwise is equal to relative_increment.
|
||||
positive impact for Truvi, otherwise is equal to relative_increment.
|
||||
This value is specially created for formatting in PBI
|
||||
|
||||
- name: monthly_aggregated_metrics_history_by_deal
|
||||
|
|
@ -2323,3 +2323,188 @@ models:
|
|||
Relative difference between the current year YTD and the YTD target,
|
||||
with a sign to represent if the relative difference is good (positive) or bad
|
||||
(negative) for our business.
|
||||
|
||||
- name: mtd_aggregated_metrics_by_deal
|
||||
description: |
|
||||
This model aggregates the historic information of our business by providing
|
||||
different metrics at account level (by id_deal).
|
||||
Additionally it provides Deal attributes.
|
||||
|
||||
data_tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
- date
|
||||
- metric
|
||||
- id_deal
|
||||
columns:
|
||||
- name: year
|
||||
data_type: int
|
||||
description: Year number of the given date.
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: month
|
||||
data_type: int
|
||||
description: Month number of the given date.
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: day
|
||||
data_type: int
|
||||
description: Day monthly number of the given date.
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: is_end_of_month
|
||||
data_type: boolean
|
||||
description: Is end of month, 1 for yes, 0 for no.
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: is_current_month
|
||||
data_type: boolean
|
||||
description: |
|
||||
Checks if the date is within the current executed month,
|
||||
1 for yes, 0 for no.
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: is_end_of_month_or_yesterday
|
||||
data_type: boolean
|
||||
description: |
|
||||
Checks if the date is end of month or yesterday,
|
||||
1 for yes, 0 for no.
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: first_day_month
|
||||
data_type: date
|
||||
description: |
|
||||
First day of the month corresponding to the date field.
|
||||
It comes from int_dates_mtd logic.
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: date
|
||||
data_type: date
|
||||
description: |
|
||||
Main date for the computation, that is used for filters.
|
||||
It comes from int_dates_mtd logic.
|
||||
data_tests:
|
||||
- not_null
|
||||
- latest_date_is_yesterday
|
||||
|
||||
- name: id_deal
|
||||
data_type: string
|
||||
description: |
|
||||
Unique ID for a deal, or account.
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: deal
|
||||
data_type: string
|
||||
description: |
|
||||
Combination of the ID and the Name of the deal.
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: active_accommodations_per_deal_segmentation
|
||||
data_type: string
|
||||
description: |
|
||||
Segment value based on the number of listings booked in 12 months
|
||||
for a given deal and date.
|
||||
data_tests:
|
||||
- not_null
|
||||
- accepted_values:
|
||||
values:
|
||||
- "0"
|
||||
- "01-05"
|
||||
- "06-20"
|
||||
- "21-60"
|
||||
- "61+"
|
||||
- "UNSET"
|
||||
|
||||
- name: main_billing_country_iso_3_per_deal
|
||||
data_type: string
|
||||
description: |
|
||||
ISO 3166-1 alpha-3 main country code in which the Deal is billed.
|
||||
In some cases it's null.
|
||||
|
||||
- name: business_scope
|
||||
data_type: string
|
||||
description: |
|
||||
Business scope identifying the metric source.
|
||||
data_tests:
|
||||
- not_null
|
||||
- accepted_values:
|
||||
values:
|
||||
- "Old Dash"
|
||||
- "New Dash"
|
||||
- "API"
|
||||
- "UNSET"
|
||||
|
||||
- name: account_manager
|
||||
data_type: string
|
||||
description: |
|
||||
Account manager of the deal.
|
||||
In some cases it's null.
|
||||
|
||||
- name: deal_lifecycle_state
|
||||
data_type: string
|
||||
description: |
|
||||
Lifecycle state of the deal.
|
||||
|
||||
- name: metric
|
||||
data_type: text
|
||||
description: Name of the business metric.
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: order_by
|
||||
data_type: integer
|
||||
description: |
|
||||
Order for displaying purposes. Null values are accepted, but keep
|
||||
in mind that then there's no default controlled display order.
|
||||
|
||||
- name: number_format
|
||||
data_type: text
|
||||
description: Allows for grouping and formatting for displaying purposes.
|
||||
data_tests:
|
||||
- accepted_values:
|
||||
values:
|
||||
[
|
||||
"integer",
|
||||
"percentage",
|
||||
"currency_gbp",
|
||||
"converted_metric_currency_gbp",
|
||||
]
|
||||
|
||||
- name: value
|
||||
data_type: numeric
|
||||
description: |
|
||||
Numeric value (integer or decimal) that corresponds to the MTD computation of the metric
|
||||
at a given date. Note that if the month is not in progress, then this value corresponds
|
||||
to the monthly figure.
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: previous_year_value
|
||||
data_type: numeric
|
||||
description: |
|
||||
Numeric value (integer or decimal) that corresponds to the MTD computation of the metric
|
||||
on the previous year at a given date.
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: relative_increment
|
||||
data_type: numeric
|
||||
description: |
|
||||
Numeric value that corresponds to the relative increment between value and previous year value,
|
||||
following the computation: value / previous_year_value - 1.
|
||||
|
||||
- name: relative_increment_with_sign_format
|
||||
data_type: numeric
|
||||
description: |
|
||||
Relative_increment value multiplied by -1 in case this metric's growth doesn't have a
|
||||
positive impact for Truvi, otherwise is equal to relative_increment.
|
||||
This value is specially created for formatting in PBI
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue