ServicesSalesforce consultingArchitectureImplementationOrg health checkDevelopmentIntegrations and APIsData migrationTesting and QAManaged supportSpecialist supportMarketing Cloud auditDeliverability
SolutionsMarketing Cloud EngagementMarketing Cloud NextSalesforce + BrazeAccount EngagementData Cloud (Data 360)Identity resolutionInsights and segmentsAgentforce and AIMCP integrationsSales and Service CloudReal-time personalisationIntegration solutionsEnterprise AI integrationBy industry
ArchitectureSalesforce CRMData 360Salesforce + BrazeAgentforceCustomer 360API-led integrationEvent-drivenMCP host, client and serverIdentity and consentMCP securityData governanceCI/CD and releasesOur public MCP server
ResourcesEngineering journalDecision guidesSolution blueprintsSalesforce productsProjects and achievementsSales ROI calculatorWhere we workChecklists and templatesPlanning toolsReadiness assessmentGlossaryAbout GeekMidstOur approachOur expertiseContact
CompanyAbout GeekMidstOur approachDelivery methodologyTrust and evidenceProjectsAchievementsBook a consultationContactWhere we workSecurity and data
Book a Consultation

Calculated Insights: Build and Troubleshoot

Calculated insights turn raw orders and engagement into lifetime value, recency and frequency. This guide covers how to build them and why they fail.

Type
Article
Topic
Data Cloud
Reading time
5 min
Updated
Author
GeekMidst Team
Reviewed by
Site owner
Blue and green data blocks with service icons arranged on a platform

A marketing team wants a segment of customers who have spent more than a set amount in the last year and bought at least twice. The data is all in Data Cloud, yet the attribute they need does not exist anywhere. That is the job of a calculated insight: a SQL definition that aggregates data in your data model into reusable measures, keyed to a profile, that segmentation and activation can use.

This guide covers how calculated insights are structured, a worked example, and the problems we see most often when they are first implemented.

Diagram showing Sales Order DMO records joined through the Unified Link Individual object to Unified Individual, aggregated into a calculated insight dimension and measures used in segmentation
Orders carry source customer IDs, so the insight must join through the link object before aggregating measures against the Unified Individual ID. View full size

What a calculated insight is

A calculated insight is defined in SQL over Data Model Objects. It produces a result set made of:

  • Dimensions, the fields you group by. For segmentation on people, one dimension must be the identifier of the profile you segment on, typically the Unified Individual ID.
  • Measures, the aggregated values, such as total spend, order count or most recent order date. Measures must be aggregates (SUM, COUNT, MAX, MIN, AVG and so on).

Calculated insights are processed in batch on a schedule you set. They are different from streaming insights, which work on near real-time data within time windows and are aimed at triggering actions rather than long-term metrics. If you need lifetime value or twelve-month frequency, a calculated insight is the right tool.

Before you start

The example below assumes:

  • Identity resolution has run, so a Unified Individual DMO and its link object exist. See How Identity Resolution Match Rules Work.
  • Orders are mapped to the standard Sales Order DMO, with the customer reference populated on each order.
  • You have looked up the exact DMO and field API names in Data Explorer. The names below follow common conventions but are samples; the unified objects in particular can carry a suffix specific to your ruleset.

A worked example: spend and frequency per unified customer

The insight below joins orders to unified individuals through the link object, then aggregates spend and order count over roughly the last year.

sql
SELECT
  ui.ssot__Id__c                       AS unified_individual_id__c,
  SUM(so.ssot__GrandTotalAmount__c)    AS spend_12m__c,
  COUNT(DISTINCT so.ssot__Id__c)       AS orders_12m__c,
  MAX(so.ssot__OrderStartDate__c)      AS last_order_date__c
FROM ssot__SalesOrder__dlm so
JOIN UnifiedLinkIndividual__dlm ul
  ON so.ssot__SoldToCustomerId__c = ul.SourceRecordId__c
JOIN UnifiedIndividual__dlm ui
  ON ul.UnifiedRecordId__c = ui.ssot__Id__c
WHERE so.ssot__OrderStartDate__c >= DATE_ADD(CURRENT_DATE, -365)
GROUP BY ui.ssot__Id__c
Sample only: confirm object names, field names and supported date functions for your org

A few things to notice:

  • Output names end in __c. Calculated insight dimensions and measures are named with this suffix; the editor will flag names it does not accept.
  • The join goes through the link object. Orders reference source customer IDs, not unified IDs. Joining orders straight to Unified Individual on the source ID returns nothing, which is one of the most common first-build errors.
  • COUNT(DISTINCT ...) on the order ID. If you join to order lines anywhere, a plain COUNT inflates frequency.
  • The date filter. Date function support differs between SQL dialects. Check the supported function list in the Data Cloud SQL reference and validate the result against a known customer before publishing.

MAX of a date is a valid measure, but for segmentation you may find "days since last order" easier to use. Derive it carefully: a value calculated against the current date at processing time drifts until the next refresh, so make sure the refresh schedule matches how the segment is used.

Troubleshooting by symptom

What goes wrong and where to look

Likely causeHow to check
Insight saves but returns no rowsJoin on the wrong ID, often source ID to unified IDRun each join separately and count rows at every step
Values far higher than finance reportsJoin fan-out from order lines or duplicate link rowsCompare spend per customer against the source system for five known customers
Insight not offered in segment builderNo dimension tied to the segmented profile's IDConfirm one dimension is the Unified Individual ID and the insight has processed
Figures look staleRefresh ran before identity resolution or ingestion completedCompare job timestamps for ingestion, resolution and the insight
Validation error on saveNon-aggregated measure, unsupported function or bad aliasRead the error, simplify the query, and add clauses back one at a time
Numbers change after a ruleset editUnified IDs were rebuiltExpected; re-baseline and tell segment owners

Sequencing refreshes

Calculated insights depend on everything upstream: ingestion, mapping, identity resolution and sometimes other insights. If the insight runs before the resolution job finishes, new customers are missing and recently merged customers can be counted against stale IDs. Write the order down, check job completion times for a week after go-live, and adjust schedules so each layer finishes before the next begins. Monitoring Data Cloud Jobs and Refresh Schedules covers this in more depth.

Design tips that save rework

  • Agree definitions with finance or analytics first. Does spend include tax, shipping, cancelled orders and returns? Write the rule down before writing SQL.
  • Keep one insight per business concept. A single huge insight with twenty measures is harder to debug and to change.
  • Choose grain deliberately. Most marketing measures belong at the unified individual level. Account-level measures for B2B need their own design.
  • Name measures for humans. Marketers will see these in the segment builder. spend_12m__c is clearer than m1__c.
  • Reconcile before launch. Pick five to ten customers, calculate their values by hand from the source system, and compare.

Checklist

  1. Upstream objects mapped, populated and resolved.
  2. Business definitions written and agreed.
  3. API names confirmed in Data Explorer.
  4. Each join validated with row counts.
  5. Results reconciled against the source for sample customers.
  6. Refresh schedule set after resolution, and before segment publish.
  7. Segment owners told what the measure means and how often it updates.

Workflow diagram

Explore how the pieces fit together. Select a step to read what happens there.

Workflow

Calculated insights

Open full size
Calculated insightsAn analyst turns a business question into measures and dimensions, then builds either a batch calculated insight or a streaming insight. Results are validated against source totals; if they reconcile they are used in segments and activation, otherwise the logic is fixed.Calculated insightsAnalystBatch insightStreaminginsightConsumersNoYesYesNoBusiness need: Metric to act on. Start from a decision, for example "who has spent most in the last year". An insight nobody uses still costs processing on every run.Business needMetric to act onDefine the metric: Measures and grain. Write down the measure (sum, count, latest), the dimension it is grouped by (usually the unified individual) and the filters. Agree the definition before building.Define the metricMeasures and grainNear real-time need?. Most insights are batch. Use a streaming insight only when the value must react within minutes, such as activity in a recent time window.Near real-timeneed?Batch insight: SQL or builder. Built with SQL or the visual builder over data model objects and run on a schedule. Check joins carefully; a join on the wrong key quietly double counts.Batch insightSQL or builderStreaming insight: Rolling time window. Calculated continuously over incoming engagement data within a time window. Keep the logic small; streaming insights support a narrower set of functions than batch.Streaming insightRolling time windowValidate results: Against source data. Compare totals and a handful of known customers with the source system. Most insight defects are mapping or join problems, not SQL syntax.Validate resultsAgainst source dataNumbers reconcile?. Only publish when the results match the source within an agreed tolerance and the people who will use them have seen the examples.Numbersreconcile?Fix the logic: Then validate again. Trace the gap: missing source rows, a wrong mapping, a bad join or timezone handling. Fix it at the cause, rebuild the insight and validate it again.Fix the logicThen validate againSegments and activation: Filter, attribute. The validated insight can be used as a segment filter, sent as an activation attribute or shown on the profile.Segments andactivationFilter, attributeStartProcess stepDecisionSystem or platformPerson or teamAlert or exceptionEnd or outcomeOriginal GeekMidst explanatory diagram, not an official Salesforce reference.

Select any step in the diagram, or use Step through, to see what happens at that point and why.

Text version: every step in order
  1. Business need AnalystMetric to act on

    Start from a decision, for example "who has spent most in the last year". An insight nobody uses still costs processing on every run.

    Next: Define the metric

  2. Define the metric AnalystMeasures and grain

    Write down the measure (sum, count, latest), the dimension it is grouped by (usually the unified individual) and the filters. Agree the definition before building.

    Next: Near real-time need?

  3. Near real-time need? Analyst

    Most insights are batch. Use a streaming insight only when the value must react within minutes, such as activity in a recent time window.

    Next: No: Batch insight; Yes: Streaming insight

  4. Streaming insight Streaming insightRolling time window

    Calculated continuously over incoming engagement data within a time window. Keep the logic small; streaming insights support a narrower set of functions than batch.

    Next: Validate results

  5. Batch insight Batch insightSQL or builder

    Built with SQL or the visual builder over data model objects and run on a schedule. Check joins carefully; a join on the wrong key quietly double counts.

    Next: Validate results

  6. Validate results AnalystAgainst source data

    Compare totals and a handful of known customers with the source system. Most insight defects are mapping or join problems, not SQL syntax.

    Next: Numbers reconcile?

  7. Numbers reconcile? Analyst

    Only publish when the results match the source within an agreed tolerance and the people who will use them have seen the examples.

    Next: Yes: Segments and activation; No: Fix the logic

  8. Segments and activation ConsumersFilter, attribute

    The validated insight can be used as a segment filter, sent as an activation attribute or shown on the profile.

    End of the flow.

  9. Fix the logic AnalystThen validate again

    Trace the gap: missing source rows, a wrong mapping, a bad join or timezone handling. Fix it at the cause, rebuild the insight and validate it again.

    End of the flow.

An analyst turns a business question into measures and dimensions, then builds either a batch calculated insight or a streaming insight. Results are validated against source totals; if they reconcile they are used in segments and activation, otherwise the logic is fixed. Original GeekMidst explanatory diagram; not an official Salesforce reference architecture.

Need insights your marketers can trust?

We can help define measures with your analytics team, build and reconcile the SQL, and set refresh schedules that line up with resolution and segment publishing.

Talk to a Data Cloud specialist →

Tell us what you are trying to fix.

Share your Salesforce setup, goals and constraints. A practitioner reads every message and replies with questions, first thoughts or an honest view of whether you need outside help at all.

Talk to a Salesforce Expert
Book a Consultation