I have a similar problem as discussed in this article (https://community.powerbi.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/m-p/547907 ;sharing this as the explanation is good and the data is available), but for me I have 15 variable vs 3 shown in the article.
Is there a way to dynamically calculate the Summarize and SUMX based on the variables used in the Matrix. E.g. When Name and Category1 is in the Matrix, the measure would summarize the table on Name and Category1 and calculate SUMX; when Category2 and Category1 is in the Matrix, the measure would summarize the table on Category2 and Category1 and calculate SUMX; and so on.
So I my case, I can put in any of the 15 variables I have and achieve the result with just 1 measure. Nested IF would not work because I would have 15! combinations.