Try total() around the entire calc. If that does not work, can you turn a small amount of data into shareable data here in a packaged workbook? Are the data sources joined or are you using datablending? We need a bit more information to know how the data is structured.
You might also be interested in Tableau Prep to work with the data before bringing into Tableau.