The TOTALMTD function evaluates an expression from the first day of the month in the current context to the last day in the current context.
TOTALMTD(
expression,
dates
[, filter]
)
- expression: Expression that returns a scalar.
- dates: Column containing dates.
- filter: Optional argument. Filter to apply to the current context.
The TOTALMTD function returns a scalar representing the expression given as the first argument evaluated for dates between the first day of the month in the current context and the last day in the current context.
This function identifies the last day of the current context and considers all dates from the first day of the month to which that day belongs to this last day. This means that if in the current context more than one month is involved, only the last one is considered.
The following functions are equivalent:
TOTALMTD(expression, dates[, filter])
CALCULATE(expression, DATESMTD(dates)[, filter])
If we consider the following table containing information on sales:
...we define the following measure:
Ventas = SUM(Ventas[Importe])
...and then we define the "Ventas MTD" measure that calculates the total sales from the beginning of the month of the current context to the last date of the current context:
Ventas MTD = TOTALMTD(
Ventas[Ventas],
Calendario[Fecha]
)
If we take this last measure to a matrix, we obtain the following result:
It can be seen how the measure is reset to zero at the beginning of each month.