PREVIOUSYEAR

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

Syntax

PREVIOUSYEAR(
    dates
    [, year_end_date]
)

Parameters
  • dates: Column containing dates.
  • year_end_date: Optional argument. Text string that defines the end of the year date (the default is December 31).
Returned value

The PREVIOUSYEAR 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 year 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.

The year_end_date argument is a text string containing a date in the local computer format and allows you to specify an end of the year other than December 31st. Although this argument must include a year (for example, "10/21/2016"), only the day and month are considered.

Examples

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

Ventas = SUM(FactSales[SalesAmount])

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

Ventas año anterior = CALCULATE(
    [Ventas],
    PREVIOUSYEAR(DimDate[Datekey])
)

...calculating the sales of the previous year, and we take these measures to a matrix with months and years at the head of the rows, the result is the following:

PREVIOUSYEAR function. Example of use

It can be seen how, for each month and for each year, the measure returning the sales of the previous year coincide with the total sales of the year that ends the month of December prior to the month of the current context.

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