Roll-Up Summary fields are an incredibly useful tool in Salesforce. They allow you to create Sums, Counts, and more for objects that share a Master-Detail relationship. However, there are many object relationships that are defined by Lookup fields. A Lookup relationship is more flexible than a Master-Detail relationship, but does not inherit some of the built-in functionality of a Master-Detail relationship. You cannot use Roll-Up Summary fields to create a Sum or Count for objects related with a Lookup field, but we still often want to be able to do this!
As it turns out, you are in luck! With the powers of Flow Builder and Process Builder, you can create a Summary or Count field to populate values on objects that do not share a Master-Detail relationship.
Let’s take a look at our use case, and how to build a new Flow and a Process to populate a count field.
Below is our data model. We have a custom object called Projects. The Projects object is related to the Account object via a lookup field on the Project object. We have also added a Number field to the Account object called Project Count Total. This field is where we want to populate the total number of Project records associated with an Account record.

Once you have defined the objects you want to count, and the number field where you will store that count value, you can follow the steps in the video below to create a Roll-Up Summary field for your objects.
Now that you have covered the basics of creating a count field, where else can you use this tool? You can add additional filters to the “Get Records” element to create a filtered count to count only records that meet certain criteria. Also once this field is populated, you can use it in Dynamic Lightning Pages to filter specific components based on the value in this summary field. For example, if there are no related projects, then you could add a reminder to your users to add one.
Edited to add:
This solution does not run on record delete. This Flow is triggered by a record update or creation, so it would not recount on record delete.
Related resources: