Admins

4 Ways to Create Roll-Up Summary Fields on Lookup Relationships in Salesforce

By Vasilis Papanikolaou

Creating roll-up summary fields on the master object in a Master-Detail relationship is relatively straightforward. The majority of Salesforce Admins will be comfortable creating roll-up summary fields, as well as the limitations around them. Speaking of limitations, roll-up summaries are really easy to set up, but they only work for Master-Detail relationships! There are two very popular (and old) ideas on the subject but it seems the ability to create roll-up summary fields on Lookup relationships won’t be coming anytime soon.

In this article we’ll review your options for working around this limitation, and dive into the various ways you can create a roll-up summary on a Lookup relationship in Salesforce. 

What is a Roll-Up Summary Field?

A roll-up summary field is one that aggregates data from a child object to a parent object that share a Master-Detail relationship. Roll-up summary fields can use the COUNT, SUM, MIN and MAX functions. For example, we could use a roll-up summary field to display the total value (amount) from Opportunities on a related Account. 

Even better, roll-up summary fields can have filter criteria, so we could choose to display the total Opportunity value from won opportunities on a related Account. 

Unfortunately, roll-up summary fields are only available for objects in a Master-Detail relationship and are not available for those that have a Lookup relationship. 

4 Ways to Create a Roll-Up Summary in Salesforce

There are 4 ways one can work around this:

  1. An AppExchange App
  2. A Flow
  3. Apex Triggers
  4. Reporting

Each of these methods has its pros and cons. 

#SolutionProsCons
1AppExchange App• Easy setup

• Tested

• No development

• More efficient for multiple fields

• More advanced functionality

• Licensing costs
2Flow• No coding skills required
• No licensing
• Effort to build and test
3Trigger• More flexible compared to flow
• No licensing
• Effort to build and test
• Needs coding skills
4Reporting• Relatively low effort
• No licensing
• Rolled up metrics not available as fields in the record
• Not visible in list views
• Not usable in flows, triggers, validations & formulas

Salesforce Native Solutions

There are multiple ways of creating a roll-up summary field on a Lookup relationship using native Salesforce functionality, but the most powerful AND accessible way is to use Flow. 

Rolled-up values in reports have many limitations and need to be created for each report you wish to see the values in. 

You could use an APEX trigger, however this requires coding skills and if any changes are required in future, an Admin won’t be able to easily update a trigger. 

Check out our complete walk-through on how to create roll-up summary fields using Flow here.

AppExchange Solutions

There are a number of app listings in the AppExchange that can do roll-ups on Lookup relationships, as well as an open-source tool.

Some example include:

Rollup Helper is easy to use and there’s a limited free version. DLRS is a good alternative if cost is an issue and you’re ok with just community support since it’s an open-source project.

Check out our guides, complete with walk-throughs, on how to use Rollup Helper and DLRS to create roll-up summary fields on lookup relationships!

Summary

Now you understand the various options available to you, don’t forget to take a look at our guides:

What’s your favorite way to create roll-up summary fields on Lookup relationships? Let us know in the comments!

The Author

Vasilis Papanikolaou

Vasilis is a Salesforce consultant, developer and Partner at Robin Consulting.

Comments:

    Justin
    January 26, 2022 2:25 pm
    Just a quick correction for anyone doing a search for the tool - it's actually DLRS (declarative lookup rollup summary), not DRLS. Or, the link above works just as well. I've used this one, and for what I've used it for, it works really well. Never tried using the Flow method though.
    Christine Marshall
    January 26, 2022 2:31 pm
    Thanks for spotting the typo! I've corrected this now :)
    Tal
    January 26, 2022 4:26 pm
    How do you do it with report?
    Tom Peppers
    January 26, 2022 8:50 pm
    I think it's also important to make mention of Andrew Fawcett's blog post about the future or DLRS - https://andyinthecloud.com/2021/07/25/the-future-of-dlrs/
    Neil
    January 26, 2022 10:37 pm
    Just started using DRLS, which seems like a pretty neat solution. Hadn't considered the flow route, but I like your thinking!
    Iris Collis
    January 27, 2022 1:28 am
    Your articles, really help solidify the concepts I am learning. Thank you!
    Anil Nair
    January 27, 2022 1:42 am
    Comprehensive summary and very helpful. Here are some details with a code sample for approach #3 (Trigger approach) that may help developers. http://varasi.com/salesforce/implementing-roll-up-summary-when-you-are-dealt-with-a-lookup-relationship/
    Christine Marshall
    January 27, 2022 9:41 am
    Thanks for reading Neil!
    Christine Marshall
    January 27, 2022 9:41 am
    Thanks for reading Iris!
    Christine Marshall
    January 27, 2022 9:43 am
    Hi Tom - we do link out to this in our blog post dedicated to DLRS: https://www.salesforceben.com/guide-to-salesforce-dlrs-declarative-lookup-roll-up-summaries/
    Vasilis Papanikolaou
    January 31, 2022 1:07 pm
    Hi Tal, You can create custom report types that include the related objects you want to report on. If you're interested in account hierarchy reports, you can look into this question from the trailblazer community: https://trailhead.salesforce.com/trailblazer-community/feed/0D54S00000A8WCaSAN
    Ike Wagh
    March 23, 2022 2:35 pm
    I mispell this all the time! For me, I keep trying to type "DSLR" because it's a common camera type. However, one trick that helps me to remember the acroynm is the name "Dolores" --> DoLoReS --> DLRS. Basically I just have to picture Dolores Umbridge from Harry Potter :)
    Padhmapriya
    April 02, 2022 11:03 am
    Flow works well too in case if anyone doesn’t want to use the app. App may be useful when the requirement is in many objects, otherwise Flow should be enough.
    Leonardo
    May 05, 2022 8:25 pm
    Example shows roll up summary created in Account using opportunity field. Isn't relationship between Account and opportunity is Lookup?
    Christine Marshall
    May 06, 2022 12:01 pm
    Hi Leonardo! The relationship between Account and Opportunity is a special type of lookup relationship in Salesforce! Salesforce treats specific standard object relationships in a hybrid way e.g. they combine lookup and master-detail functionality. We've simply used the Account/Opp example to demonstrate what a roll-up looks like and what functionality it provides. Hope this clarifies things for you!
    SJ
    July 21, 2022 3:23 pm
    How do you then add a rollup summary to calculate number of accounts related to a contact using flow? Do we use the same trigger ?

Leave a Reply