DATESMTD

The DATESMTD function returns a table with a single column that contains the dates from the beginning of the month in the current context to the last date in the current context.

Syntax

DATESMTD(
    dates
)

Parameters
  • dates: Column containing dates.
Returned value

The DATESMTD function returns a table.

Additional Information

The dates argument can be a reference to a column containing dates, an expression that returns a table with a single column containing dates, or a Boolean expression that defines a table with a single column containing dates.

The current month always starts on day 1 (not customizable).

This function considers the last day of the current context and returns a table containing all the 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.

Depending on the context in which it is used, the result may not be as expected. In such a case, we must make sure that we have marked the calendar table as "date table" (by selecting the table in the Fields column and executing the Table Tools > Calendars > Mark as date table command):

Mark as date table
Examples

The following sales table is considered in this example:

DATESMTD function. Example of use

The Ventas measure is defined:

Ventas = SUM(Ventas[Importe])

...now we create the Ventas MTD measure that calculates accumulated sales since the beginning of the month:

Ventas MTD = CALCULATE(
    Ventas[Ventas],
    DATESMTD(Calendario[Fecha])
)

If we take these measures to a matrix, we obtain the following result:

DATESMTD function. Example of use

It can be seen how the measure is reset to zero at the beginning of each month.

Category
Time intelligence
Submitted by admin on Tue, 12/04/2018 - 11:53