Have you utilized Tableau Level of Detail expressions? They will allow you to do what you want. See the example on this page for Percent of Total: Top 15 LOD Expressions | Tableau Software
That should get you going but come back if you have any questions. Ideally, if you have a workbook (.twbx) file to share then it is more likely someone here will jump in and show an example of how to accomplish what you like with something that looks closer to your own data.
I hope that helps.