The AVERAGEX function returns the arithmetic mean of the values returned by an expression that is evaluated for all rows in a table.
AVERAGEX(
<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 AVERAGEX function returns a real number.
The function evaluates the expression included as the second argument for each of the rows of the indicated table, returning the arithmetic mean of the values obtained. Only numeric values and dates are considered: the function does not accept non-numeric values or null cells. When there are no values to calculate the arithmetic mean for, the function returns a BLANK. When there are rows but none meet the appropriate criteria, the function returns 0.
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 extract the average sale price of the sales made with the following measure:
Precio medio = AVERAGEX(Ventas,Ventas[Precio])
...obtaining the following result (taken to a "Card" type display):
If, in the previous scenario, we wanted to calculate the arithmetic mean of the value of the invoices issued (that is, the sale price considering the number of products sold), we could do so with the following measure:
Precio medio = AVERAGEX(Ventas,Ventas[Precio]*Ventas[Cantidad])
...obtaining the following result (taken to a "Card" type display):