← Portfolio
SQL Methodology

GTM Metric Calculations

Five example metric queries, with calculation rules, assumptions, and policy choices. The tables describe a proposed Salesforce and billing schema.

Snowflake SQL examples · Tested with small local fixtures · Not connected to a warehouse

Qualified PipelinePipeline
Current ACV of open opportunities in Qualified, Demo, Proposal, or Negotiation.
›

Current ACV of open opportunities in Qualified, Demo, Proposal, or Negotiation. The example assumes one row per opportunity and account. Direct stage filtering avoids multiplying amounts through a repeated stage lookup.

-- Qualified Pipeline: Current ACV of all open opportunities at Stage 2+
-- Example owner: Rev Ops | Proposed refresh: Daily 6:00 AM ET | Source: Salesforce Opportunity
SELECT
o.owner_name AS rep,
a.specialty_segment AS specialty,
o.lead_source AS source_channel,
COUNT(*) AS deal_count,
SUM(o.acv) AS pipeline_acv,
AVG(o.acv) AS avg_deal_size,
MEDIAN(o.acv) AS median_deal_size
FROM salesforce.opportunity o
JOIN salesforce.account a
ON o.account_id = a.account_id
WHERE o.stage_name IN ('Qualified', 'Demo', 'Proposal', 'Negotiation')
AND o.is_closed = FALSE -- Exclude won and lost
AND o.acv >= 5000 -- Floor: exclude sub-$5K trials
AND o.is_deleted = FALSE
GROUP BY 1, 2, 3
ORDER BY pipeline_acv DESC;
Edge Cases & Guards
·Excludes Prospecting (Stage 1) — these haven't been validated by Sales yet
·Excludes deals < $5K to filter out free trials and POCs that inflate pipeline count
·Uses current ACV, not original — captures upsells and downsells during negotiation
·The is_deleted check catches Salesforce soft-deletes that can silently inflate totals
Example policy choices

Example policy choice: count opportunities from Qualified onward. Keep prospecting and unconverted leads in separate views. A real implementation needs agreement on stage names, qualification criteria, and ACV.

Implementation Notes

Local regression fixtures check repeated stages, excluded opportunities, closed-cohort denominators, and retained churn. Snowflake execution and dbt integration have not been validated. Before use, map the schema, enforce unique opportunity/account keys, confirm complete billing periods, and reconcile results to source totals.