Do you mean records in a repeating group?
Obviously a repeating section can have conditional display that might show a subset of the total records.
You should be able to get a row count or low tech is to add an additional fiels to your record set that you can use to sum.
Do you want to use code or rules?