6 Replies Latest reply on Jan 2, 2019 9:30 AM by olanrewaju.oyeyinka

# Previous Year QTD calculation

Hi,

I am trying to compare my current year and previous year QTD, but i was only able to get my current year leaving my previous year null.

I used these below and return the current year:

IF [date]<= TODAY() AND

DATEPART('quarter', date) = DATEPART('quarter',TODAY()) AND

YEAR([date) = YEAR(TODAY()) THEN

[Volume in measures]

END

thanks

larry

• ###### 1. Re: Previous Year QTD calculation

I think i did so crazy, kindly look below: is this best practice for previous year QTD calculation?

IF  DATEPART('quarter',date)=

DATEPART('quarter',TODAY())-3

and DAY(date)<=DAY(TODAY())-1

then [Volume from measure]

END

• ###### 2. Re: Previous Year QTD calculation

There are usually more than one way to solve a problem in tableau

I am partial to datetrunc (it returns an actual date) in this case the first date of the quarter

Jim

If this posts assists in resolving the question, please mark it helpful or as the 'correct answer' if it resolves the question. This will help other users find the same answer/resolution.  Thank you.

1 of 1 people found this helpful
• ###### 3. Re: Previous Year QTD calculation

Hi Jim,

Thanks for your swift response....It's actually work for only 4th quarter of the previous year and i still have little discrepancy with my figure when i validate.

someone also told me to use these...returns the same as u provide. which was a diff of (-1) from mine.

IF [date]<= TODAY() AND

DATEPART('quarter', [date]) = DATEPART('quarter',TODAY()) AND

YEAR([date]) = YEAR(TODAY())-1 THEN

[sales]

END

• ###### 4. Re: Previous Year QTD calculation

it works for the 4th quarter because it is linked to today() as is your calculations

what are your trying to do? are you trying to look at a running Q over Q?

please post your workbook in twbx format with the data so we can better understand the goal

Thanks

Jim

• ###### 5. Re: Previous Year QTD calculation

Hi Jim,

I am unable to attach the workbook to follow up with your question. I want to calculate previous year quarter over quarter. But the formula you provide just showed quarter one in the previous year.

Below is a screenshot

Larry

• ###### 6. Re: Previous Year QTD calculation

Hi Jim,

Kindly look at the attached and see the previous year QTD and previous QTD1 calculation and verify please.

It's only shows for quarter one in the previous year. couldn't see the rest of the quarter.

thanks

larry