Automatically sum line items of a module

Is there a way to sum all the line items in a module? Let's say I have 20 line items in a module at the moment and I want to sum it all up in the 21st line item.

(1) Is selecting 20 line items one by one to get the total the only way?

(2) Is there a way to ensure that if a new line item is added somewhere between 1st and 20th line item, it is automatically added to the total formula?

Tagged:

Answers

  • JaredDolich
    edited May 2023

    @saket22

    I'm not aware of a single formula that will do that but there are alternatives. What you're describing sounds like a list. Is there a way you can convert the line items to a list. A line item subset won't help you either unfortunately, which converts line items to a list because there's not aggregate level. But, if you build a list instead of line items I think you'll get the desired effect - just make sure there's a top level (or parent).

  • @JaredDolich

    Thanks for answering. Converting the line items into a list is a way to get around it but sometime we may not want to do that. Even if the number of line items is small, having the option to somehow refer to the total of all line items in a module would be very useful.

  • @saket22 Gotcha.

    Wish I had a better answer. Only other thing you might consider is creating subtotals based on some type of attribute of the line items. Then the total is the sum of the subtotals. Won't help you much if someone adds a new line item though. Generally not a good idea to create one line item that has all the other line items in it as this will eventually burden the calculation engine since all it takes is one line item to change. If the total is used in other modules or other calculations you'll probably want to break it up anyway. Also, the formula is hard to read and if you subscribe to the PLANS methodology then one formula would probably be considered sub-optimal.