Skip to content

Commit

Permalink
Merge pull request #3 from fivetran/additional_modeling
Browse files Browse the repository at this point in the history
Initial Model Build
  • Loading branch information
kristin-bagnall authored May 8, 2020
2 parents 176bc08 + c6c3a02 commit 33b1f30
Show file tree
Hide file tree
Showing 9 changed files with 600 additions and 2,795 deletions.
2,560 changes: 0 additions & 2,560 deletions logs/dbt.log

This file was deleted.

4 changes: 1 addition & 3 deletions models/base/stg_salesforce_account.sql
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ with base as (
name as account_name,
industry,
number_of_employees,
account_source,
rating as account_rating,
annual_revenue
account_source

from base

Expand Down
12 changes: 6 additions & 6 deletions models/intermediate/opportunity_aggregation_by_owner.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ with salesforce_opportunity_enhanced as (
select *
from {{ ref('salesforce_opportunity_enhanced') }}

), user as (
), salesforce_user as (

select *
from {{ ref('stg_salesforce_user') }}
Expand Down Expand Up @@ -64,12 +64,12 @@ with salesforce_opportunity_enhanced as (
)

select
user.user_id as owner_id,
salesforce_user.user_id as owner_id,
coalesce(p_manager_id, b_manager_id, l_manager_id) as manager_id,
booking_by_owner.*,
lost_by_owner.*,
pipeline_by_owner.*
from user
left join booking_by_owner on booking_by_owner.b_owner_id = user.user_id
left join lost_by_owner on lost_by_owner.l_owner_id = user.user_id
left join pipeline_by_owner on pipeline_by_owner.p_owner_id = user.user_id
from salesforce_user
left join booking_by_owner on booking_by_owner.b_owner_id = salesforce_user.user_id
left join lost_by_owner on lost_by_owner.l_owner_id = salesforce_user.user_id
left join pipeline_by_owner on pipeline_by_owner.p_owner_id = salesforce_user.user_id
123 changes: 123 additions & 0 deletions models/salesforce.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
{% docs avg_bookings_amount -%}
The average opportunity amount, if status is won.
{%- enddocs %}

{% docs avg_days_open -%}
The average days since created across opportunties in the pipeline.
{%- enddocs %}

{% docs avg_days_to_close -%}
The average days to close across opportunties in that have been won.
{%- enddocs %}

{% docs avg_pipeline_opp_amount -%}
The average opportunity amount, if status is pipeline.
{%- enddocs %}

{% docs bookings_amount_closed_this_month -%}
The opportunity amount, if closed this month and status is won.
{%- enddocs %}

{% docs bookings_amount_closed_this_quarter -%}
The opportunity amount, if closed this quarter and status is won.
{%- enddocs %}

{% docs bookings_count_closed_this_month -%}
The opportunity count, if closed this month and status is won.
{%- enddocs %}

{% docs bookings_count_closed_this_quarter -%}
The opportunity count, if closed this quarter and status is won.
{%- enddocs %}

{% docs largest_booking -%}
The largest amount associated with a single opportunity.
{%- enddocs %}

{% docs largest_deal_in_pipeline -%}
The largest amount associated with a single opportunity in the current pipeline.
{%- enddocs %}

{% docs lost_amount_this_month -%}
The opportunity amount, if closed this month and status is lost.
{%- enddocs %}

{% docs lost_amount_this_quarter -%}
The opportunity amount, if closed this quarter and status is lost.
{%- enddocs %}

{% docs lost_count_this_month -%}
The opportunity count, if closed this month and status is lost.
{%- enddocs %}

{% docs lost_count_this_quarter -%}
The opportunity count, if closed this quarter and status is lost.
{%- enddocs %}

{% docs owner_id -%}
Id of the owner of this opportunity
{%- enddocs %}

{% docs pipeline_count_created_this_month -%}
The opportunity count, if closed this month and status is pipeline.
{%- enddocs %}

{% docs pipeline_count_created_this_quarter -%}
The opportunity count, if closed this quarter and status is pipeline.
{%- enddocs %}

{% docs pipeline_created_amount_this_month -%}
The opportunity amount, if closed this month and status is pipeline.
{%- enddocs %}

{% docs pipeline_created_amount_this_quarter -%}
The opportunity amount, if closed this quarter and status is pipeline.
{%- enddocs %}

{% docs pipeline_created_forecast_amount_this_month -%}
The opportunity amount mulitplied by the forecast percentage, if closed this month and status is pipeline.
{%- enddocs %}

{% docs pipeline_created_forecast_amount_this_quarter -%}
The opportunity amount mulitplied by the forecast percentage, if closed this quarter and status is pipeline.
{%- enddocs %}

{% docs total_bookings_amount -%}
The opportunity amount, if status is won.
{%- enddocs %}

{% docs total_lost_amount -%}
The opportunity amount, if status is lost.
{%- enddocs %}

{% docs total_number_bookings -%}
The opportunity count, if status is won.
{%- enddocs %}

{% docs total_number_lost -%}
The opportunity count, if status is lost.
{%- enddocs %}

{% docs total_number_pipeline -%}
The opportunity count, if status is pipeline.
{%- enddocs %}

{% docs total_pipeline_amount -%}
The opportunity amount, if status is pipeline.
{%- enddocs %}

{% docs total_pipeline_forecast_amount -%}
The opportunity amount mulitplied by the forecast percentage, if status is pipeline.
{%- enddocs %}

{% docs total_win_percent -%}
The booking amount closed, divided by the sum of the booking amount and the lost amount..
{%- enddocs %}

{% docs win_percent_this_month -%}
The booking amount closed this month, divided by the sum of the booking amount closed this month and the lost amount this month.
{%- enddocs %}

{% docs win_percent_this_quarter -%}
The booking amount closed this quarter, divided by the sum of the booking amount closed this quarter and the lost amount this quarter.
{%- enddocs %}
Loading

0 comments on commit 33b1f30

Please sign in to comment.