Home » DAX » DAX – PREVIOUSDAY Function

DAX – PREVIOUSDAY Function

PREVIOUSDAY DAX function

Returns a table that contains a column of all dates representing the day that is previous to the first date in the dates column, in the current context.

It’s comes under Time & Intelligence Dax function Category.

Syntax:

PREVIOUSDAY(<dates>)




Description:

Dates – A column with dates.

Note:

This function determines the first date in the input parameter, and then returns all dates corresponding to the day previous to that first date.

For example, if the first date in the dates argument refers to Sept 13, 2020; this function returns all dates equal to Sept 12, 2020.

So, Let’s start with an example, download the sample Dataset from below link





Step-1: Create a measure to calculate previous day sale.

PREVIOUSDAY = 
CALCULATE(SUM(Orders[Sales]), 
PREVIOUSDAY(Orders[Order Date]))

Step-2:  Drag Order Date, Sales & Previous Day measure to table visual to check the output.

PreviousdayDAX1

Previousday DAX Output – 1

So, you can see here it returns the previous day sales against current date.

Points to remember here:




If some dates are missing in your data set then it will return blank as in previous sales value.

Here, 03/04/2020 Order date is missing so, it return blank sales value against 04/04/2020.

Previousday DAX -2

Previousday DAX -2

Step-3: Drag one more Region column in table visual and see the change behavior-




Now, it is showing region wise previous day sales, you can see in below screen shot, for Central – 01/01/2015 sales is 36.58, so it will return same sales for Central – 02/01/2015 & same for other regions.

Previousday DAX-3

Previousday DAX-3

Recommended Post : PREVIOUSMONTH DAX Function

Hope you enjoyed the post. Your valuable feedback, question, or comments about this post are always welcome or you can leave us message on our contact form , we will revert to you asap.



Leave a Reply