Is it possible to create a calculation that sums the number of related records that share a unique ID?

If I have a table <grocery bag>, filled with <items>.

<items> can have unique IDs for "fruit" or "vegetables".

So if your shopping back has (6) cherries and (10) bananas) sharing the uniqueID type-1000 (fruit), is there a way for the shopping cart to calculate there are a total of (16) pieces of fruit, even though there are only (2) records for these <items>. (Which is to say FM is counting the number of records that contain the uniqueID field "type-1000"?

Thanks so much for your help!

The easiest way is with ExecuteSQL() :

The harder way is a Sum() calculation via a filtered relationship.

However, either way becomes more difficult if you want to return multiple categories from the same cart without making fields for each category sum calc.