The SUMX function returns the sum of the values taken by an expression that is evaluated for all the rows in a table.
SUMX(
table,
expression
)
- table: Table containing the rows for which the expression will be evaluated.
- expression: Expression to evaluate for each row of the table.
The SUMX function returns a real number.
The function evaluates the expression included as the second argument for each of the rows of the indicated table, adding all the results and returning this value. Only numerical values are considered, ignoring Blanks, Boolean values and texts.
The table argument can be either a table or a function that returns a table.
Suppose we have the following table showing the sales list, including the number of items sold and their unit price:
We can define the following measure:
Ventas totales = SUMX(Ventas, Ventas[Cantidad] * Ventas[Precio])
...which performs the Quantity * Unit Price calculation for each of the rows and adds these partial values. If we take the measurement to a card-type display, we obtain the desired result: