There's more...

To demonstrate how you must tailor this recipe depending upon the context in which the measure is used within visualizations, perform the following steps:

  1. Create the following measures:
SumTotal 2 = 
IF(
HASONEVALUE('R05_Table'[Category1]),
[Sum],
VAR __Table = SUMMARIZE('R05_Table','R05_Table'[Category1],"__value",[Sum])
RETURN
SUMX(__Table,[__value])
)

SumTotal 3 =
IF(
HASONEVALUE('R05_Table'[Category2]),
[Sum],
VAR __Table = SUMMARIZE('R05_Table','R05_Table'[Category2],"__value",[Sum])
RETURN
SUMX(__Table,[__value])
)

SumTotal 4 =
IF(
HASONEVALUE('R05_Table'[Category1]) && HASONEVALUE('R05_Table'[Category2]),
[Sum],
VAR __Table = SUMMARIZE('R05_Table','R05_Table'[Category1],'R05_Table'[Category2],"__value",[Sum])
RETURN
SUMX(__Table,[__value])
)
  1. Create a second Table visualization and place the Category1 column, as well as the Sum and SumTotal 2 measures, in the Values area for the visualization.
  2. Create a third Table visualization and place the Category2 column, as well as the Sum and SumTotal 3 measures, in the Values area for the visualization.
  3. Create a fourth Table visualization and place the Category1 and Category2 columns, as well as the Sum and SumTotal 4 measures, in the Values area for the visualization.
  4. Create a Matrix visualization and place the Category1 and Category2 columns in the Rows area of the visualization, as well as the Sum and SumTotal 4 measures, in the Values area for the visualization.
Note that the total lines for the SumTotal 2, SumTotal 3, and SumTotal 4 measures are correct within their respective visualizations, but that the total line for the Sum measure is incorrect. Also note that the HASONEVALUE and SUMMARIZE statements for SumTotal 2, SumTotal 3, and SumTotal 4 correspond with how information is grouped within the visualizations in which they are used.