Jump to content

Calculating the sum of related records.


This topic is 7448 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

Let's say record Parent1 is related to three records ChildA, ChildB, and ChildC. (If it matters, I am imagining the relationship working by ChildA, ChildB, and ChildC all having the value Parent1 in their Parent field.)

The children have a field called Score. Parent1 has a field called Total. I want Total to hold the sum of the children's Score field.

I can do this by having a script run down a portal, total them up and stuff the result in Total. It seems, however, there should be an easier way, using a calculation or a summary field.

Ideas anyone?

Much Grass.

(I am starting to mess around with FM7, so if a solution is easier in 7 let me know.)

Posted

The solution in FM7 is that the "Total" field is a summary that is a total of Child::Score, the summaries only work over the set of related records.

If I remember correctly, FM6 computed summaries from other tables using the found-set in that table, so I think you could do a "go to related record" to get the correct found set in the Child file, then the summary setup in Parent will be correct when you switch back to it?

Posted

The solution in FM7 is that the "Total" field is a summary that is a total of Child::Score, the summaries only work over the set of related records.

When I try a Summary field, there seems to be no way to get a total of a related field. However, from your suggestion I made Total a Calculation field = Sum(Child::Score), and it worked perfectly.

Thanks

Drew

This topic is 7448 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.