Learn how to use the Transform element in Salesforce Flow to sum and count items from a collection without loops — faster, cleaner, and more efficient for after-save record-triggered flows.
Big idea
The Transform element in Salesforce Flow lets you map and aggregate values from a source collection into a single target value. Instead of building loops and using Assignment elements to total amounts or count items, you can use Transform to perform aggregation (sum, count) in one step. Note: as of Spring ’25 the Transform element is available only in after-save record-triggered flows.
Business use case
Example: when an Account record is updated, find all related open Opportunities and calculate the total sum of their Amount fields. This is a common requirement for rollups and business metrics without creating Apex or custom rollup objects.
Step-by-step: Build the flow
Follow these high-level steps in Flow Builder:
- Start — Create a Record-Triggered Flow (after-save) on Account, trigger on create or update, optimized for Action and Related Records.
- Get Records — Use Get Records to retrieve related Opportunity records where AccountId = {!$Record.Id} and IsClosed = {!$GlobalConstant.False}. Store all records and select the Opportunity fields you need (Id, Name, StageName, AccountId, OwnerId, Amount).
- Transform — Add a Transform element. Set Source Data to the Get Records collection. For Target Data choose Data Type = Currency (or Number for counts) and uncheck Allow multiple values. Map the source collection to the target and choose Aggregate Type = Sum and Field to Transform = Amount. For counting items choose Aggregate Type = Count and Data Type = Number.
Why this matters
Using Transform reduces complexity, improves readability, and makes flows run faster by removing the need for loops and manual assignments. It’s ideal for rollups, dashboards, and any scenario where you need a calculated aggregate from a related record collection.
Key takeaways
- Transform supports aggregation (Sum, Count) over a source collection.
- Transform is available in after-save flows (Spring ’25+) — not in before-save record-triggered flows.
- Use Get Records to gather the collection, then Transform to aggregate.
Best practices
- Limit Get Records with filters to avoid returning excessive rows (stay well under 50k rows).
- Store only the fields you need in Get Records to improve performance.
- For multi-currency orgs, consider currency conversion — Transform may not expose converted fields directly; use alternate approaches (Apex, formula fields, or additional data retrieval) if you need a single-currency aggregation.
In summary, Transform brings modern collection transformation and aggregation to Flow Builder — use it to replace loops when summing or counting related records.
Why this matters for Salesforce professionals:
Admins and developers can build cleaner automations faster, cut down on flow complexity, and reduce maintenance overhead. Business users benefit from more reliable rollups and near-real-time calculations that power dashboards and KPIs.








Leave a Reply