Microsoft Office Tutorials and References
In Depth Information
If you try to use the SUM function to aggregate the expression, you get another error (see
Figure 6-6) although different.
FIguRE 6-6 You get an error message when you use SUM with an expression as parameter.
As you can see in Figure 6-6, you cannot use an expression as an argument of the SUM
function because the SUM function works only with a column as a parameter and does
not accept a generic expression. However, you can obtain the result you want by using a
SUMX( Orders, Orders[Quantity] * Orders[Price] )
The SUMX aggregation function iterates the table passed as the first parameter (Orders),
and for each row of the table makes the calculation specified in the second parameter
(Orders[Quantity] * Orders[Price]). The expression is evaluated in a row context
corresponding to the current row of the iteration. The result of the expression for each row is
summed up for all the rows, and the SUMX function returns the result of this aggregation,
as shown in Figure 6-7.