7 Replies Latest reply on May 26, 2016 7:03 AM by deanchampeau

# Using sum function on repeating field from related table

Hello,

I have an Estimate Line Items table that has a repeating field which shows the estimated cost of a task across 5 different quantity levels. The Estimate Line Items table is a child table to the Estimates table, where I have a portal showing that same repeating field. I'd like to perform a sum of all the costs for each of the 5 field repetitions across all related records, and put the result into a Total Cost repeating field in the parent table. I've been trying to use the sum function to accomplish this, to no avail. I've tried a variety of syntaxes but can't seem to get it right.

Can the sum function be used in this way with repeating fields in related records, or am I barking up the wrong tree?

Thanks everyone!

Dean

• ###### 1. Re: Using sum function on repeating field from related table

deanchampeau wrote:

am I barking up the wrong tree?

You're already done that by using a repeating field …

Anyway, try this: create a summary field Total of: cost, with “Summarize repetitions: Individually” in the line items table, and put that on your Estimates layout.

• ###### 2. Re: Using sum function on repeating field from related table

Yeah, you're probably right... I was kind of embarrassed even to ask this question, having used a repeating field for this.

Summary fields are found-set dependent, right? If I used your approach, wouldn't that require the found set from which the summary field gets its values be the correct found set (just the set of records that are related to the parent record)? I could try to ensure that this is the case through layout design, but it still seems a bit dangerous.

Maybe I'm better off ditching the repeating fields and using distinct fields for each quantity level?

• ###### 3. Re: Using sum function on repeating field from related table

deanchampeau wrote:

Summary fields are found-set dependent, right? If I used your approach, wouldn't that require the found set from which the summary field gets its values be the correct found set (just the set of records that are related to the parent record)?

They are also related-set dependent. Just try it out.

• ###### 4. Re: Using sum function on repeating field from related table

Don't be embarrassed to ask a question. We all learn from each other. Even in rare cases where a response sounds harsh, just keep in mind that we all are here out of a desire to help each other.

The community overall is a great one.

• ###### 5. Re: Using sum function on repeating field from related table

Super cool! Thank you, Eroist! I always assumed that summary fields acted on founds sets. I didn't realize you could use them on portals acting on related records.

Thanks again!

Dean

• ###### 6. Re: Using sum function on repeating field from related table

You can take it a few steps further with Filtered Portals, too. See if this article gives you some ideas.

Get the demo file!

beverly

• ###### 7. Re: Using sum function on repeating field from related table

Excellent reference, Beverly. Thanks.