Merged PR 3967: Adds an "All History" time window to Account Margin
# Description Quick improvement to be able to report the same setup of metrics by considering all account history up to a certain date. It adds a new computation flow for this All History window. Note that I needed to update the macro to override this case by using unbounded preceding. I also took the opportunity to update the exposures of the new report. # 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: #26085
This commit is contained in:
parent
f5e417c7db
commit
0ec1484846
5 changed files with 136 additions and 2 deletions
|
|
@ -6,6 +6,105 @@ with
|
|||
int_hubspot__deal as (
|
||||
select * from {{ ref("int_hubspot__deal") }}
|
||||
),
|
||||
metric_aggregation_all_history as (
|
||||
select
|
||||
date,
|
||||
id_deal,
|
||||
main_deal_name,
|
||||
main_billing_country_iso_3_per_deal,
|
||||
deal_lifecycle_state,
|
||||
'All History' as time_window,
|
||||
{{
|
||||
calculate_aggregation_between_preceeding_x_and_y(
|
||||
"date", "min", "id_deal", "date", "", 1, True
|
||||
)
|
||||
}},
|
||||
{{
|
||||
calculate_aggregation_between_preceeding_x_and_y(
|
||||
"date", "max", "id_deal", "date", "", 1, True
|
||||
)
|
||||
}},
|
||||
{{
|
||||
calculate_aggregation_between_preceeding_x_and_y(
|
||||
"created_bookings", "sum", "id_deal", "date", "", 1, True
|
||||
)
|
||||
}},
|
||||
{{
|
||||
calculate_aggregation_between_preceeding_x_and_y(
|
||||
"listings_booked_in_month", "avg", "id_deal", "date", "", 1, True
|
||||
)
|
||||
}},
|
||||
{{
|
||||
calculate_aggregation_between_preceeding_x_and_y(
|
||||
"total_revenue_in_gbp", "sum", "id_deal", "date", "", 1, True
|
||||
)
|
||||
}},
|
||||
{{
|
||||
calculate_aggregation_between_preceeding_x_and_y(
|
||||
"total_guest_payments_in_gbp", "sum", "id_deal", "date", "", 1, True
|
||||
)
|
||||
}},
|
||||
{{
|
||||
calculate_aggregation_between_preceeding_x_and_y(
|
||||
"xero_operator_net_fees_in_gbp", "sum", "id_deal", "date", "", 1, True
|
||||
)
|
||||
}},
|
||||
{{
|
||||
calculate_aggregation_between_preceeding_x_and_y(
|
||||
"xero_apis_net_fees_in_gbp", "sum", "id_deal", "date", "", 1, True
|
||||
)
|
||||
}},
|
||||
{{
|
||||
calculate_aggregation_between_preceeding_x_and_y(
|
||||
"xero_waiver_paid_back_to_host_in_gbp",
|
||||
"sum",
|
||||
"id_deal",
|
||||
"date",
|
||||
"",
|
||||
1,
|
||||
True
|
||||
)
|
||||
}},
|
||||
{{
|
||||
calculate_aggregation_between_preceeding_x_and_y(
|
||||
"xero_host_resolution_amount_paid_in_gbp",
|
||||
"sum",
|
||||
"id_deal",
|
||||
"date",
|
||||
"",
|
||||
1,
|
||||
True
|
||||
)
|
||||
}},
|
||||
{{
|
||||
calculate_aggregation_between_preceeding_x_and_y(
|
||||
"xero_host_resolution_payment_count",
|
||||
"sum",
|
||||
"id_deal",
|
||||
"date",
|
||||
"",
|
||||
1,
|
||||
True
|
||||
)
|
||||
}},
|
||||
{{
|
||||
calculate_aggregation_between_preceeding_x_and_y(
|
||||
"revenue_retained_in_gbp", "sum", "id_deal", "date", "", 1, True
|
||||
)
|
||||
}},
|
||||
{{
|
||||
calculate_aggregation_between_preceeding_x_and_y(
|
||||
"revenue_retained_post_resolutions_in_gbp",
|
||||
"sum",
|
||||
"id_deal",
|
||||
"date",
|
||||
"",
|
||||
1,
|
||||
True
|
||||
)
|
||||
}}
|
||||
from int_monthly_aggregated_metrics_history_by_deal
|
||||
),
|
||||
metric_aggregation_previous_12_months as (
|
||||
select
|
||||
date,
|
||||
|
|
@ -359,6 +458,9 @@ with
|
|||
from int_monthly_aggregated_metrics_history_by_deal
|
||||
),
|
||||
metric_aggregation_by_deal as (
|
||||
select *
|
||||
from metric_aggregation_all_history
|
||||
union all
|
||||
select *
|
||||
from metric_aggregation_previous_12_months
|
||||
union all
|
||||
|
|
|
|||
|
|
@ -1438,6 +1438,7 @@ models:
|
|||
- not_null
|
||||
- accepted_values:
|
||||
values:
|
||||
- All History
|
||||
- Previous 12 months
|
||||
- Previous 6 months
|
||||
- Previous 3 months
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue