The Power BI PREVIOUSDAY function is one of the DAX Date and Time functions useful to return a table that contains all the previous day’s dates based on the given date. This article explains the POWER BI DAX PREVIOUSDAY function that accepts the value of the date and uses the current context to return a column of all dates corresponding to the day previous to the first date in the given input and the syntax is shown below.
PREVIOUSDAY(<dates>)
Power BI DAX PREVIOUSDAY function Example
To demonstrate the DAX PREVIOUSDAY() function, click the New Table button on the Modeling Tab and rename it as PreviousDay. The below expression uses the FactInternetSales table. It creates a table of all the previous day’s dates to the first date in the OrderDate column.
To show the same, we have added the OrderDate, PREVIOUSDAY, Order Quantity, and Sales Amount to the table report. Please refer to the DateTime and the function article for the remaining Power BI methods. For more Charts >> Click Here.
PreviousDay = PREVIOUSDAY(FactInternetSales[OrderDate])
The PREVIOUSDAY expression below creates a simple measure. It calculates and shows the sum of the Sales Amount of the previous OrderDate day in the FactInternetSales table. To compare present-day sales against previous-day sales, we have added the OrderDate, Sales Amount, and the sum of the previous-day and next-day sales to the table.
PreviousDaySales = CALCULATE(SUM(FactInternetSales[SalesAmount]), PREVIOUSDAY(FactInternetSales[OrderDate]))