How to get total of rows based on a column value?

Your rollup column is pointing to the sheet, so it sums everything in the sheet. You need to point it to the relation so it only sums the data with the same unique id.