Merged PR 3914: Include Hubspot deals for KPIs
# Description Context: I'm intending to work on Account Managers reporting, that mostly will include reporting at Deal level the Resolutions Payouts as well as the new Retained metrics. While checking the great increase on Resolutions Payouts for October 2024:  I decided to take a quick look into the main players... and surprise surprise we have Guesty:  So Guesty represents 37k over the 73K of October. 50%. Not bad. The main issue is that we've been aware for months now (since Churn efforts, mostly) that we're not reporting in KPIs those deals that are NOT created in Core. Most notably, API deals which includes... well, Guesty. So creating this kind of in-depth Account Managers improvement without reporting Guesty I think it would be very misleading. Note that the overall figures (Global dimension) are still accurate, though. What's new: * A new model named `int_kpis__dimension_deals` that basically retrieves Deals from both Core (as before) and Hubspot. It combines information from both and mostly assumes Hubspot as a better source of information than Core - although we do not have the Main Billing Country there afaik. * Propagates changes, mostly in the monthly by deal view of Main KPIs. Here I confirm that now Guesty appears, and it only has metrics that come from Xero (APIs Revenue, Total Revenue, Resolutions, etc) # 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: #25829
This commit is contained in:
parent
29a005297a
commit
0d7b5ac88a
6 changed files with 82 additions and 12 deletions
|
|
@ -10,9 +10,9 @@ with
|
|||
ikdd.day,
|
||||
ikdd.date,
|
||||
-- Dimensions --
|
||||
coalesce(icuh.id_deal, 'UNSET') as id_deal,
|
||||
coalesce(ikd_deals.id_deal, 'UNSET') as id_deal,
|
||||
coalesce(
|
||||
icd.main_billing_country_iso_3_per_deal, 'UNSET'
|
||||
ikd_deals.main_billing_country_iso_3_per_deal, 'UNSET'
|
||||
) as main_billing_country_iso_3_per_deal,
|
||||
coalesce(
|
||||
icmas.active_accommodations_per_deal_segmentation, 'UNSET'
|
||||
|
|
@ -26,12 +26,11 @@ with
|
|||
end as is_end_of_month_or_yesterday
|
||||
from {{ ref("int_kpis__dimension_dates") }} as ikdd
|
||||
left join
|
||||
{{ ref("int_core__user_host") }} as icuh
|
||||
on ikdd.date >= icuh.created_date_utc
|
||||
left join {{ ref("int_core__deal") }} as icd on icuh.id_deal = icd.id_deal
|
||||
{{ ref("int_kpis__dimension_deals") }} as ikd_deals
|
||||
on ikdd.date >= ikd_deals.effective_deal_start_date_utc
|
||||
left join
|
||||
{{ ref("int_kpis__dimension_daily_accommodation") }} as icmas
|
||||
on icuh.id_deal = icmas.id_deal
|
||||
on ikd_deals.id_deal = icmas.id_deal
|
||||
and ikdd.date = icmas.date
|
||||
where (ikdd.is_month_to_date = true or ikdd.is_end_of_month)
|
||||
)
|
||||
|
|
|
|||
25
models/intermediate/kpis/int_kpis__dimension_deals.sql
Normal file
25
models/intermediate/kpis/int_kpis__dimension_deals.sql
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
{{ config(materialized="table", unique_key="id_deal") }}
|
||||
with
|
||||
hubspot_deals as (
|
||||
select id_deal, deal_name as main_deal_name, live_date_utc as deal_start_date
|
||||
from {{ ref("int_hubspot__deal") }}
|
||||
where live_date_utc is not null
|
||||
),
|
||||
core_deals as (
|
||||
select
|
||||
id_deal,
|
||||
main_deal_name,
|
||||
first_created_date_utc as deal_start_date,
|
||||
main_billing_country_iso_3_per_deal
|
||||
from {{ ref("int_core__deal") }}
|
||||
)
|
||||
select
|
||||
coalesce(hd.id_deal, cd.id_deal) as id_deal,
|
||||
coalesce(hd.main_deal_name, cd.main_deal_name) as main_deal_name,
|
||||
cd.main_billing_country_iso_3_per_deal,
|
||||
min(
|
||||
coalesce(hd.deal_start_date, cd.deal_start_date)
|
||||
) as effective_deal_start_date_utc
|
||||
from hubspot_deals hd
|
||||
full outer join core_deals cd on hd.id_deal = cd.id_deal
|
||||
group by 1, 2, 3
|
||||
|
|
@ -425,6 +425,46 @@ models:
|
|||
has been offboarded on the 5th day, this column will be false
|
||||
for the days 1st to 4th, and true from the day 5th onwards.
|
||||
|
||||
- name: int_kpis__dimension_deals
|
||||
description: |
|
||||
This model provides the main baseline for deals for KPIs.
|
||||
It combines deals from both Hubspot and Core. In case of a deal
|
||||
being present in both systems, Hubspot data will take precedence
|
||||
in terms of deal name. Besides, the model provides the main billing
|
||||
country according to core, in case core deals exist. Lastly, the first
|
||||
date considered as effective date corresponds to the minimum between the
|
||||
date a deal has gone live according to Hubspot and the first date a user
|
||||
host has been created according to Core.
|
||||
|
||||
columns:
|
||||
- name: id_deal
|
||||
data_type: string
|
||||
description: ID of the account, or deal.
|
||||
tests:
|
||||
- not_null
|
||||
- unique
|
||||
- name: main_deal_name
|
||||
data_type: string
|
||||
description: |
|
||||
Main deal name according to Hubspot. In case of a deal being present
|
||||
in both systems, Hubspot data will take precedence in terms of deal name.
|
||||
tests:
|
||||
- not_null
|
||||
- name: main_billing_country_iso_3_per_deal
|
||||
data_type: string
|
||||
description: |
|
||||
Main billing country of the host aggregated at Deal level according to
|
||||
Core. It can be null if the deal is only present in Hubspot or if the
|
||||
field is null in Core.
|
||||
- name: effective_deal_start_date_utc
|
||||
data_type: date
|
||||
description: |
|
||||
Effective start date of the deal, which corresponds to the minimum between the
|
||||
date a deal has gone live according to Hubspot and the first date a user
|
||||
host has been created according to Core.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: int_kpis__dimension_daily_accommodation
|
||||
description: |
|
||||
This model computes the deal segmentation per number of
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue