Integration Guide

Segment Salesforce Deals by Size and Flag Statistical Outliers

Loading and transforming Salesforce Opportunity data into Snowflake

By Ishan Rastogi Last updated: July 10, 2026

The problem: bucket deals by size and flag outliers

A $900K opportunity sitting alongside twenty $30K deals skews the pipeline mean and makes forecasts unreliable. To catch this, you need Salesforce Opportunity data in a warehouse — segmented by deal size, with statistical outliers flagged — updated on a schedule, not as a one-off CSV export. This pipeline produces two outputs:

Tier distribution

Group every deal into one of three size buckets and show deal count and share of total pipeline revenue per tier.

TierDeal CountTier Revenue% of Total Revenue
Under $50K142$3,373,20018.0%
$50K–$200K89$8,452,60045.1%
Over $200K23$6,914,20036.9%

Outlier detection (Amount > mean + 2σ)

Flag individual deals whose Amount is more than two standard deviations above the mean — in this dataset, that threshold is $370,100. Those deals distort averages and need separate handling in forecasting models.

OpportunityAmountStageClose Dateσ above mean
ACME Corp — Enterprise Renewal$890,000Closed Won2026-06-305.5
Beta Industries — Global Expansion$620,000Negotiation/Review2026-08-153.7
Delta Co — Platform Upgrade$415,000Proposal/Price Quote2026-09-012.3

To produce both outputs on a schedule, this guide uses DataStori — an agentic ELT platform that ingests Salesforce Opportunity data directly into Snowflake and runs the tier distribution and outlier detection as a versioned transformation pipeline, all without writing extraction or transformation code by hand.

Solution outline

1

Find the right Salesforce API

Identify which Salesforce API exposes the Opportunity data and what query parameters it requires — without reading the full API documentation by hand. DataStori reads the live Salesforce docs and surfaces the right endpoint with a confidence score.

2

Build and run an ingestion pipeline

Generate an incremental pipeline that fetches Opportunity records into Snowflake on a schedule — handling OAuth authentication, Bulk API pagination, and deduplication automatically, without writing pipeline code.

3

Document the ingested data

Catalog the field names, types, and primary keys of what was ingested so the downstream transformation has a reliable, versioned schema to work from. This happens automatically after the first pipeline run.

4

Run the analytics transformation

Describe the tier-bucketing and outlier-detection logic in plain language. DataStori generates the transformation script from the data catalog, registers it as a versioned pipeline, and writes the output — deal-size tiers and outlier flags — to your own cloud storage on every run.

Step 1: Finding the right Salesforce API

Salesforce exposes dozens of APIs and hundreds of endpoints. The one needed here is the SOQL query endpoint on the Bulk API — it accepts SQL-like queries and returns large record sets in batches. Rather than reading the Salesforce API documentation to find it, describe the goal in plain language in DataStori's AI Pipeline Builder and let it identify the right endpoint automatically, reading the live Salesforce API docs and returning each candidate with a confidence score.

DataStori AI Pipeline Builder chat with Salesforce selected and the pipeline goal entered in plain language, the agent analyzing the request
Describe the goal in plain language — DataStori reads the live Salesforce API docs and proposes endpoints.
DataStori showing 8 discovered Salesforce endpoints at 80% confidence with a Register API and Continue button
The agent returns discovered endpoints with confidence scores. Click Register API to proceed.

Select the SOQL query endpoint — the Bulk API endpoint that accepts SOQL statements and returns Opportunity records in batches. Custom __c fields are included automatically; no per-object connector configuration is needed.

Endpoint selection list in DataStori with 'Query Opportunity records via SOQL' checked among the discovered Salesforce SOQL endpoints
Select the Salesforce SOQL query endpoint. Custom objects appear alongside standard ones.

Step 2: Ingesting the Opportunity table into Snowflake

With the endpoint confirmed, DataStori generates the full pipeline configuration: OAuth 2.0 authentication, SOQL query parameters, Bulk API pagination, incremental tracking on SystemModstamp, and primary-key deduplication on every run. You review and confirm — no pipeline code is written.

  1. Connect Salesforce over OAuth 2.0. DataStori auto-detects the grant flow (Client Credentials for unattended runs). Enter your Connected App credentials and test the connection.
    Salesforce OAuth 2.0 credentials form in DataStori with Client ID, Client Secret, token endpoint login.salesforce.com/services/oauth2/token, and a Test and Connect button
    Authorize over OAuth 2.0 and verify the connection before proceeding.
  2. Review the generated configuration. Confirm the SOQL query, Bulk API pagination, API host, and incremental cursor the agent proposed, then create the pipeline. Schema is documented automatically.
    DataStori pipeline review screen showing the SOQL q query parameter, pagination settings, and a Create 1 Pipeline button
    Review the generated pipeline configuration — SOQL query, pagination, incremental cursor — then create it.
  3. Run and schedule. Trigger an initial full load or put the pipeline on a recurring schedule. Incremental runs filter on SystemModstamp, deduplicating on the primary key and capturing soft-deleted records via queryAll.
    DataStori dashboard showing the Salesforce pipeline execution with COMPLETED status and 'Pipeline ran successfully' messages
    Runs complete automatically. Status, duration, and row counts are visible on the dashboard.

Pipelines run entirely in your own cloud. Salesforce data moves directly to your Snowflake destination; DataStori orchestrates the run and stores only pipeline metadata — your business data never passes through DataStori's servers.

Step 3: Data catalog — Opportunity table auto-documented in DataStori

Once the first run completes, the Opportunity table is available in Snowflake with its schema automatically documented by DataStori. Standard fields — Id, Name, Amount, StageName, CloseDate, ExpectedRevenue — and any custom __c fields are all present, deduplicated on the primary key and ready for the transformation step. See how DataStori handles schema evolution when Salesforce adds or renames fields between runs.

DataStori Data Catalog showing the Opportunity table storage locations
DataStori Data Catalog showing the Opportunity table with the locations where the data is stored. Note the table description is auto-generated by DataStori.
DataStori Data Catalog showing the Opportunity table with Id, Name, Amount, StageName, CloseDate, and ExpectedRevenue columns
DataStori Data Catalog showing the Opportunity table with Id, Name, Amount, StageName, CloseDate, and ExpectedRevenue columns. The column description is auto-generated by DataStori.
Snowflake Snowsight worksheet showing loaded Salesforce Opportunity rows with Id, Name, Amount, StageName, CloseDate, and ExpectedRevenue columns
Flattened and deduplicated opportunity records in Snowflake, schema auto-documented, ready for the transformation pipeline.

Step 4: Running the tier distribution and outlier detection transformations

4.1 — Define the data model

Before running any transformation, navigate to DataStori's data model window. This is where you define the relationships between your ingested tables and the metrics you want to compute. For a Salesforce-only analysis the Opportunity table is the single source, but if you want to join it with data from other sources — a CRM, a billing system, a product database — this is the right place to build those joins. The data model you define here acts as the semantic layer that the automated transformation in step 4.2 reads from, so the output is grounded in relationships you control rather than assumptions the system makes on its own.

DataStori data model window showing the Salesforce Opportunity table with its fields and relationship configuration panel
Define table relationships and metrics in the data model window before running transformations. This acts as the base layer for all downstream pipelines.

4.2 — Run the automated transformation

With the data model in place, open the Transformation Workspace and describe the computation in plain language. DataStori reads the data catalog and the data model, identifies the Opportunity table and its columns, and generates a complete PySpark script that computes deal-size tiers and outlier flags, then writes both Delta and CSV output to the gold layer of your own cloud storage.

DataStori Transformation Workspace chat with a request to bucket Salesforce Opportunity deals by size and flag outliers, showing the generated PySpark script with INPUT_PATHS and a Script ready banner
Describe the transformation goal — the assistant generates the full PySpark script using your live data catalog.

Name the transformation and save it. DataStori stores the script as a versioned artifact and registers it as a schedulable pipeline in the Transformation Catalog alongside your ingestion pipelines.

Create Transformation Pipeline dialog in DataStori with the pipeline named 'deal size' and a Create Pipeline button
Name and save the transformation — stored as a versioned script, schedulable independently of the ingestion pipeline.
Transformation Pipelines catalog showing the 'deal size' transformation with v1 script version, monthly schedule, and a run submitted confirmation
The transformation appears in the catalog with its script version and schedule. Trigger on demand or let it run automatically.
DataStori Pipeline Runs dashboard showing the 'deal size' transformation with COMPLETED status and 'Pipeline ran successfully' message
The transformation run completes and reports its status alongside ingestion runs on the same dashboard.

Because transformations run in your cloud, output lands in the gold layer of your cloud storage — Delta format for downstream pipelines, CSV for direct inspection — next to the Salesforce silver data it read from.

AWS S3 console showing the transformation output folder with both a csv subfolder and a delta subfolder
Both Delta and CSV are written on every run — Delta for pipelines, CSV for direct inspection.

The CSV contains each Opportunity row tagged with its deal-size tier, an is_outlier flag, and the mean and standard deviation used to compute it. You can push this data to snowflake or consume it directly from your cloud storage.

CSV output in a code editor showing real Salesforce Opportunity rows with deal_size_tier, is_outlier, mean_amount, and stddev_amount columns
Each Opportunity row tagged with deal-size tier and outlier flag, ready to load into BI or open directly.

Aggregating the row-level output produces the two target tables from the problem statement:

See a Salesforce to Snowflake pipeline built live.
Book a demo

Frequently Asked Questions

Does DataStori support Salesforce custom objects?

Yes. DataStori auto-discovers objects and fields from your Salesforce org, including custom objects and fields (the ones ending in __c). You do not need a pre-built connector for each object.

How are Salesforce updates and deletes handled in Snowflake?

Incremental runs filter on SystemModstamp to capture new and changed records, and use the queryAll operation to capture soft-deleted records. DataStori deduplicates on the primary key so your Snowflake tables reflect the current state without duplicates.

Does my Salesforce data pass through DataStori's servers?

No. Pipelines run entirely in your own cloud. Salesforce data moves directly to your Snowflake destination. DataStori orchestrates the pipeline and can only access metadata, never the business data itself.

Can DataStori handle large Salesforce volumes and API limits?

Yes. High-volume objects are extracted through the Salesforce Bulk API, which is built for large data volumes and avoids the per-page limits of the synchronous REST API.

What Snowflake data formats does DataStori deliver?

Data lands in Delta (the default), Iceberg, Parquet, or CSV, in your own cloud storage and Snowflake. Data volume is unlimited on every plan.