SugarCRM Developer Blog

HOWTO: Use Sugar Logic Rollups

13 Feb, 2012
Posted By: John Mertic

A great new feature that came with Sugar 6.3 is the ability to do rollups, meaning that you can do a calculation over a single field in all of the related records of a related module. You can do four different types of rollups in Sugar 6.3:

  • rollupMax – return the max value of all of the related module records
  • rollupMin – return the min value of all of the related module records
  • rollupSum – return the sum value of all of the related module records
  • rollupAve – return the average value of all of the related module records
  • count – return the total number of related module records

Here’s a great use case for this; suppose you want to add a field to the Accounts module which sums the average Opportunity amount for an account. Just add a new field with this equation as the calculated field:

rollupAve($opportunities,"amount")

Or maybe you are looking for the total number of Cases submitted by a Contact. Try this formula on a new field:

count($cases,"amount")

This enables all sorts of new abilities. Have you used these fields? If so, sound off in the comments on how you use these functions.

  • SJakobsson

    I Love this new feature however I need to add a date parameter, as in make the sum only count the records added in the last 30 days. I am working on making a custom formula top achieve this. Can you point me to the Type of expression these are?

  • http://twitter.com/jmertic John Mertic

    Could you add a feature request bug for this at http://bugs.sugarcrm.com? Sugar Logic is always being improved upon, and we welcome any and all feedback you have it making it more useful.

    Thanks!

  • SJakobsson

    Hi me again, I have raised a ticket and I am trying to work around the issue in the meantime. I created some calculated fields which mean that the value of one field will be 0 if the date is not within my date range. However now I found another issue, namely that the roll Up is telling me it cannot use a calculated field. Is there a workaround for this?

  • http://twitter.com/jmertic John Mertic

    From our Eng team…

    The workaround is to do it manually from the vardef extension rather than from studio. However, this has been disabled as under some circumstances the rollup doesn’t always work correctly (I don’t recall the exact cases).  It is something that I think we should invest in supporting in a later version since there are many use cases for this.

Have feedback for us? Drop us a line.
Terms & Conditions | Privacy | Trademark Info | Contact Info | FAQs | SugarCRM Inc.© 2004 - 2009 All rights reserved.