You have two options depending on the design of your layout and their respective tables.
If you pull up multiple classes in one found set and sort them by class, you can put the summary fields in a sub summary part "when sorted by" class and you'll get summary values for each class.
If you set up a relationship that matches by the class field, then either aggregate functions or summary fields can be used to report your statistical values for all related records.
This doesn't actually require using a portal if the relationship is sufficient to match to your set of related records. Sometimes a one row portal with a summary field in it is useful when you need to use a portal filter to get the correct group of related records to summarize.
Yes, thanks. I've been away from FM for some time, but I recall doing this for a project a few years ago. A relationship and portals it is.