'Custom Tableau Subtotal To Follow Same Logic As Custom Calc

I have a table displaying Stock Id, Cost, Profit and a custom calculated return (Profit/Cost). I've enabled subtotals for my table which is correctly displaying the sum of cost and profit, but it's also summing the return (Which is not accurate - It should be using the sum of profit/ the sum of cost. Any way to tell tableau to follow the same logic as the custom calc in the subtotal for just this field?

Correct Calc:

Stock ID    Cost    Profit    Return
A           1313    235       18%
B           2911    185       6%
C           3137    449       14%
Total       7361    869       12%

Tableau Is Showing:

Stock ID    Cost    Profit    Return
A           1313    235       18%
B           2911    185       6%
C           3137    449       14%
Total       7361    869       39%


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source