Power BI DAX PREVIOUSMONTH

The Power BI PREVIOUSMONTH function is one of the DAX Date and Time functions useful for returning a table that contains all dates from the previous month based on the first date of a given date. This article explains the POWER BI DAX PREVIOUSMONTH function, which accepts dates and uses the current context to return a column of all dates from the previous month. The syntax is shown below.

PREVIOUSMONTH(<dates>)

Power BI DAX PREVIOUSMONTH function Example

To demonstrate the DAX PREVIOUSMONTH() function, click the New Measure button on the Modeling Tab and rename it as PREVIOUSMONTH. The below expression calculates the sum of the Sales Amount of the previous month’s OrderDate in the FactInternetSales table. Please check the sales of the 30-01-2011 and 01-02-2011 dates. 

Here, 43,421.0364 is the January sales sum whereas the 4,69,823.9148 is the February 2011 sales. To show the same, we have added the OrderDate, Previous Month, Next Month, next day sales, and Sales Amount to the table report. Please refer to the DateTime and function article for the remaining Power BI methods. For more Charts >> Click Here.

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

The expression below creates a simple measure. It calculates the sum of the Sales Amount of the previous OrderDate month CalendarTable generated by the CALENDAR function. To compare present-month sales against next-month sales, we added the Year of OrderDate, Sales Amount, and the sum of the previous and next Month’s sales. For December 2010, there are no previous sales in the dataset, so it returns blank.

PreviousMonthCalSale = CALCULATE(SUM(FactInternetSales[SalesAmount]), PREVIOUSMONTH(CalendarTable[Date]))
POWER BI DAX PREVIOUSMONTH Function 2