PREVIOUSDAY

The PREVIOUSDAY function returns a table containing a column with the date corresponding to the day before the current context.

Syntax

PREVIOUSDAY(
    dates
)

Parameters
  • dates: Column containing dates.
Returned value

The PREVIOUSDAY 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 date corresponding to the day before the first day of the current context. In other words, the set of dates returned by the function (in this case only one) 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 un día antes = CALCULATE(
    [Ventas],
    PREVIOUSDAY(DimDate[Datekey])
)

...calculating the sales of the previous day, and we take both measures to a table in which we show the days of the calendar as row headings, the result is the following:

PREVIOUSUSDAY function. Example of use

In this case, the period considered in the calculation of the measure [Ventas un día antes] is the day before the current context.

If, in the previous scenario, we modify the matrix to show only the sales by months, the result is the following:

PREVIOUSUSDAY function. Example of use

In this example, each figure returned by the measure [Ventas un día antes] corresponds to the sales on the last day of the month before the one considered in the context. To confirm this, we can look at the figure returned for the month of February, € 6,501,821.28, a figure that in the table of the first scenario corresponds to the sales of January 31.

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