# Description Computes projected Bookings to the end of the current month per dimension and dimension value KPIs changes: * Adds a int_kpis__agg_daily_created_bookings model. This is a standard KPIs model that computes created bookings at a daily level per dimension and dimension value. Projected KPIs (NEW): * Adds a new folder named projected within KPIs. This includes a simple Readme. * Adds a default dimension dates model that ranges from the past 3 complete months to the end of the current month, that is in the future. * Adds 2 projected models for created bookings: The daily one, that handles the logic of the projection (same month + last 7 days) and the monthly one, that retrieves the end of month projected value as well as some indicators of how good or bad this was for previous months. How good is the projection at 11th of March (so 10 days in the month)? `select * from intermediate.int_kpis_projected__agg_monthly_created_bookings order by actual_created_bookings desc`  # 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: #28251
23 lines
842 B
SQL
23 lines
842 B
SQL
{% 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 %}
|