I would look into using Level of Detail (LOD) expressions to calculate these totals.
Introduction to LOD Expressions
Top 15 LOD Expressions
FIXED Level of Detail Expressions
The way a LOD is set up depends on the structure of the specific data set. Are you able to share a sample workbook? If the data is confidential, a sample packaged workbook with sample data that mimics the structure of the original workbook is sufficient.
I am not sure if we could use LOD to add the total amounts from two different sheets and combine it in a third sheet. The data I am using is confidential, I will try to create a sample WB. Thanks