Home » DAX » DAX – PREVIOUSQUARTER Function

DAX – PREVIOUSQUARTER Function

PREVIOUSQUARTER DAX function

Returns a table that contains a column of all dates from the previous quarter, based on the first date in the dates column, in the current context.

It’s comes under Time Intelligence DAX function category.

Syntax:

PREVIOUSQUARTER(<dates)




Description:

Dates – A column with dates.

Note:

This function returns all dates from the previous quarter, using the first date in the input column.

For example, if the first date in the dates argument refers to June 10, 2020, this function returns all dates for the quarter January to March, 2020.

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

Step-1: Create a calendar table to using existing dataset “Order Date” column.

Go to Modeling Tab > Click to table icon & write below DAX

Calendar = 
CALENDAR(MIN('Global-Superstore'[Order Date]), 
MAX('Global-Superstore'[Order Date]))





Step-2: After that create a relationship between both tables.

Relationship

Relationship

Step-3: Now, create a measure to get Previous Quarter Sale.

PREVIOUSQUARTER =
CALCULATE(SUM('Global-Superstore'[Sales]),
PREVIOUSQUARTER('Calendar'[Date]))





Step-4: Drag Year & Quarter columns from Calendar table & Sales from Global-Superstore.

PREVIOUSQUARTER DAX-1

PREVIOUSQUARTER DAX-1

So, you can see here it returns the result as per definition.



Now, Drag Year, Quarter & date column from calendar table:

PREVIOUSQUARTER DAX - 2

PREVIOUSQUARTER DAX – 2

As you see in above screen shot, it will return total sum of previous quarter sales against current quarter each dates, here previous quarter was 2011-Q1 and current quarter is 2011-Q2.

Recommended Post : PREVIOUSDAY DAX Function , PREVIOUSMONTH DAX Function , PREVIOUSYEAR 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