Loading...

Wouldn’t it be much easier for you if you could calculate the average number of closed opportunities in Salesforce? This solution is here to make things easier. A rollup summary in salesforce a field that allows you to calculate values from related records. For instance, you want to calculate the average number of closed opportunities, the average amount of closed opportunities, or the SUM, MIN, MAX number. Today, we are going to tell you how you can create rollup summary in Salesforce with flow. So, let’s just jump right into the steps!

Steps

Use Case

Here is a simple example of how to create a roll-up summary that counts how many contacts exist for a given account and keeps this number up-to-date as you add/edit contacts that are related to this account.

Create a new Account field

Starting with the Account object (where we want our counter), we create a new number field (with 0 decimal places) called Contacts Count (Contacts Count__c).

To start building this flow, create a new flow, type = Record Triggered Flow.

The object is the contact as we want to see when a change occurs on a contact record. For example, it gets related to an account. We need to do this after the contact record is saved.

create rollup Summary in Salesforce

Unfortunately, there are no filters on the contact that we can use to determine if we need to update the account contact count, so we have to check them all. It’s not a very efficient method, but it only runs when we create or update a contact record.

The ideal situation would be to only update those where the record is new or the AccountId has been added or changed. Using the changed operator would like the solution. However, it will always be true when we create a new contact as the AccountId will go from null to a valid AccountId.

create rollup Summary in Salesforce

Add a Decision element:

Now, we can add a decision to see if the AccountId has been changed. The Yes condition is for an existing contact record where the related Account (Account ID) has been changed.

create rollup Summary in Salesforce

Add a Get Records element (for Prior accounts):

Here, we want to get any contact records where the Account Id was changed on the contact. We need to update this account contact because the record may no longer be related to the account and the count needs to be recalculated.

We want to count any contact records where the Account Id is the same as the contact record that triggered this flow – before the change (they were related to the same account).

create rollup Summary in Salesforce

First, we need to create a variable to save these records to:

create rollup Summary in Salesforce

Click on New Resource to create a variable.

create rollup Summary in Salesforce

Create another variable rc_ContactsPrior

create rollup Summary in Salesforce

Back to the get records element:

create rollup Summary in Salesforce

ContactsCounterPrior variable:

Create another variable to store how many contacts were found:

create rollup Summary in Salesforce

before

Create an Assignment Element

Set our new counter to the number of contact records we found.

create rollup Summary in Salesforce

Add an Update Records Element:

Next, update the account record with the new count of contacts:

create rollup Summary in Salesforce
create rollup Summary in Salesforce

Get our contacts:

create rollup Summary in Salesforce

Add the fields we want in our record collection:

create rollup Summary in Salesforce

Create another new variable for the count of records:

create rollup Summary in Salesforce

Assign the value to the counter: (add Assignment)

create rollup Summary in Salesforce

Update our Account with the new counter value:

create rollup Summary in Salesforce
create rollup Summary in Salesforce

Save your Flow

Finally, Save and activate your flow and check if your flow looks like the one in this pic:

create rollup Summary in Salesforce

Conclusion

We hope that you liked this blog and now you can create your own roll-up summary with the flow in Salesforce. If you try out this solution, then do share your experiences with us. We will be back with another interesting blog soon.

Also, you can follow us on our social media handles to stay updated about all the latest developments in and around Salesforce. Till then, happy learning! 🙂

Related Articles

Sticky notes aren’t just for your desk anymore! In this tutorial, we’ll create a Lightning Web Component (LWC) in Salesforce that allows you to pin notes on your app page or record page. With a clean, interactive UI, these digital sticky notes ensure you never forget important tasks or details. What Will You Learn? By […]

Read More
How to Create Dynamic, Animated Charts in Salesforce LWC using Chart.js

Bring Salesforce data to life with dynamic charts inside Lightning pages! While Salesforce dashboards are powerful, sometimes business users want visual insights without leaving their current page. That’s where Chart.js with Lightning Web Components (LWC) becomes a game-changer. In this step-by-step guide, you’ll learn how to: Upload Chart.js as a static resource in Salesforce. Build […]

Read More
How to Encrypt and Decrypt Data in Salesforce Using Apex Crypto Class

Data security is more important than ever. Whether you’re storing customer information, sensitive business data, or private communication, ensuring that your data stays safe is critical. Salesforce provides built-in tools to help with this, and one of the most powerful yet easy-to-use approaches is encryption and decryption using the Apex Crypto class. In this blog, […]

Read More
Benefits & Step-by-Step Setup Guide for Salesforce Code Analyzer

When building on the Salesforce platform, code quality and security are non-negotiable, especially before submitting your app for a Salesforce Security Review. Catching bugs and vulnerabilities early not only saves time but also ensures compliance with Salesforce’s best practices. That’s where the Salesforce Code Analyzer comes in. This open-source tool scans your Apex classes, triggers, […]

Read More
A Step-by-Step Guide to Integrate Zoho CRM with Salesforce (Without Coding)

Managing data across multiple CRMs can be a real challenge for businesses that want a single source of truth. If your teams use Zoho CRM but want to move or sync all records seamlessly into Salesforce, you don’t need to write a single line of code. Thanks to MultiSync Made Easy, the integration process is […]

Read More
How to Integrate Salesforce with Copilot

Integrating Salesforce with Copilot is becoming an essential step for organizations aiming to streamline workflows, automate client data management, and unlock the power of AI-driven CRM. By connecting these two platforms, businesses can centralize customer information, reduce manual tasks, and accelerate growth. This guide walks you through the Salesforce–Copilot integration process with clear steps, Apex […]

Read More