diff --git a/macros/business_kpis_configuration.sql b/macros/business_kpis_configuration.sql index cfce33d..7a55df6 100644 --- a/macros/business_kpis_configuration.sql +++ b/macros/business_kpis_configuration.sql @@ -134,7 +134,7 @@ Provides a general assignement for the Dimensions available for each KPI {% set additional_dimensions = [] %} {# Adds Deal dimension to all models except DEAL metrics #} - {% if entity_name != "DEALS" %} + {% if entity_name not in ["DEALS", "NEW_DASH_DEALS_OFFERED_SERVICES"] %} {% set additional_dimensions = additional_dimensions + [dim_deal()] %} {% endif %} @@ -188,6 +188,15 @@ Provides a general assignement for the Dimensions available for each KPI ] %} {% endif %} + {% if entity_name == "NEW_DASH_DEALS_OFFERED_SERVICES" %} + {% set additional_dimensions = additional_dimensions + [ + dim_has_upgraded_service(), + dim_new_dash_version(), + dim_pricing_service(), + dim_pricing_business_type(), + ] %} + {% endif %} + {# Combine base dimensions with additional dimensions for the specific model #} {% set dimensions = base_dimensions + additional_dimensions %} {{ return(dimensions) }} diff --git a/models/intermediate/kpis/int_kpis__agg_daily_new_dash_deals_offered_services.sql b/models/intermediate/kpis/int_kpis__agg_daily_new_dash_deals_offered_services.sql new file mode 100644 index 0000000..95ca183 --- /dev/null +++ b/models/intermediate/kpis/int_kpis__agg_daily_new_dash_deals_offered_services.sql @@ -0,0 +1,22 @@ +{% set dimensions = get_kpi_dimensions_per_model("NEW_DASH_DEALS_OFFERED_SERVICES") %} + +{{ config(materialized="table", unique_key=["date", "dimension", "dimension_value"]) }} + + +{% for dimension in dimensions %} + select + -- Unique Key -- + d.date, + {{ dimension.dimension }} as dimension, + {{ dimension.dimension_value }} as dimension_value, + -- Metrics -- + count(distinct dos.id_deal) as deal_with_offered_service_count + from {{ ref("int_kpis__dimension_dates") }} d + left join + {{ ref("int_kpis__metric_daily_new_dash_deals_offered_services") }} as dos + on d.date = dos.date + group by 1, 2, 3 + {% if not loop.last %} + union all + {% endif %} +{% endfor %} diff --git a/models/intermediate/kpis/schema.yml b/models/intermediate/kpis/schema.yml index b0aee31..4fa1e23 100644 --- a/models/intermediate/kpis/schema.yml +++ b/models/intermediate/kpis/schema.yml @@ -7587,4 +7587,54 @@ models: description: | Main billing country of the host aggregated at Deal level. data_tests: - - not_null \ No newline at end of file + - not_null + + - name: int_kpis__agg_daily_new_dash_deals_offered_services + description: | + This model computes the dimension aggregation for Daily Deals Offered Services. + It only retrieves services that come from users that are in New Dash, as well + as it only considers services created after the user has moved to New Dash. + The primary key of this model is date, dimension and dimension_value. + + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - date + - dimension + - dimension_value + + columns: + - name: date + data_type: date + description: | + The daily date acting as time range for the metrics in this record. + data_tests: + - not_null + + - name: dimension + data_type: string + description: The dimension or granularity of the metrics. + data_tests: + - assert_dimension_completeness: + metric_column_names: + - deal_with_offered_service_count + - accepted_values: + values: + - global + - by_number_of_listings + - by_billing_country + - by_new_dash_version + - by_has_upgraded_service + - by_service + - by_service_business_type + + - name: dimension_value + data_type: string + description: The value or segment available for the selected dimension. + data_tests: + - not_null + + - name: deal_with_offered_service_count + data_type: bigint + description: | + The daily count of deals with services offered for a given date, dimension and value. \ No newline at end of file