PREVIOUSMONTH

The PREVIOUSMONTH function returns a table containing a column with the dates corresponding to the month prior to the current context.

Syntax

PREVIOUSMONTH(
    dates
)

Parameters
  • dates: Column containing dates.
Returned value

The PREVIOUSMONTH 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.

This function returns the set of dates corresponding to the month preceding the dates involved in the current context. In other words, the set of dates returned by the function is never part of the current context.

Examples

If, given a table with sales, we define the measure:

Ventas = SUM(FactSales[SalesAmount])

...calculating the total sales, and the measure:

Ventas mes anterior = CALCULATE(
    [Ventas],
    PREVIOUSMONTH(DimDate[Datekey])
)

...calculating the sales of the previous month, and we take both measures to a matrix in which we place days, months and years at the head of the rows, we obtain the following result:

PREVIOUSMONTH function. Example of use

It can be seen how the calculation of the measure [Ventas mes anterior] for the visible days of February and March coincide with the total of the previous month.

If, in the previous scenario, we take years, quarters and months to the row headers, the result is the following:

PREVIOUSMONTH function. Example of use

We can see how the calculation of the measure [Ventas mes anterior] coincides with the total sales of the previous month for both months and quarters.

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