To demonstrate the efficiency of using VAR statements, perform the following steps:
- Create the following measures:
Sum 6 =
IF(
SUMX('R11_Table','R11_Table'[Value]) = 0,
0,
SUMX('R11_Table','R11_Table'[Value])
)
Sum 7 =
VAR __Sum = SUMX('R11_Table','R11_Table'[Value])
RETURN
IF(__Sum = 0,
0,
SUMX('R11_Table','R11_Table'[Value])
)
- Create a Card visualization and place the Sum 6 measure in the Fields area of the visualization.
- Create a second Card visualization and place the Sum 7 measure in the Fields area of the visualization.
- Analyze the Card visualizations for Sum 6 and Sum 7 using Performance Analyzer.
You should see that Sum 7 consistently takes a shorter amount of time to complete than Sum 6. This is because Sum 6 performs the SUMX calculation twice, while Sum 7 only performs the SUMX calculation once.