Power BI DAX PREVIOUSYEAR function

The Power BI PREVIOUSYEAR function is one of the DAX Date and Time functions useful to return a table that contains all previous year dates based on the given date. The syntax of the PREVIOUSYEAR function is shown below. The year_end_argument argument is an optional string literal that defines the year-end date. By default, it is 31 December.

PREVIOUSYEAR(<dates>, <year_end_argument>)

Power BI DAX PREVIOUSYEAR function Example

To demonstrate the PREVIOUSYEAR() function, click the New Table button on the Modeling Tab and rename it as PREVIOUSYEAR. The below expression uses the FactInternetSales table as the reference. Next, it will create a table of all dates from the previous year based on the OrderDate column.

PREVIOUSYEAR =  PREVIOUSYEAR(FactInternetSales[OrderDate]

The below Power BI DAX PREVIOUSYEAR function expression creates a simple measure that will calculate and show the sum of the Sales Amount of the previous OrderDate year in the FactInternetSales table.

To compare both present year sales against the previous and next year’s sales, we have added the OrderDate, Sales Amount, and the sum of the previous year’s sales to the table report. Please refer to the DateTime and function article for the remaining Power BI methods. For more Charts >> Click Here.

PreviousYearSales = CALCULATE(SUM(FactInternetSales[SalesAmount]), PREVIOUSYEAR(FactInternetSales[OrderDate]))
POWER BI DAX PREVIOUSYEAR Function 1

Similarly, the following DAX formula calculates the previous year’s sales sum based on the calendar table. This table was generated by the CALENDAR function.

PreviousYearCalSale = CALCULATE(SUM(FactInternetSales[SalesAmount]), PREVIOUSYEAR(CalendarTable[Date]))
PREVIOUSYEAR Function 2