7 Replies Latest reply on Sep 1, 2015 3:29 PM by satish.parvathaneni

# How to Calculate the previous quater value...!!

Hi Every one,

Please help me out in one issue, the requirement is that based on the date selection from the date filter, my table should show me the current quater vale and previous quater value.

E.g lets say if i select 31/3/2015 then it show me current quater sales value and previous quater sales value.

• ###### 1. Re: How to Calculate the previous quater value...!!

Hi Nakul,

Try this calculation and parameter.

IF datediff('quarter',[date1],[Order Date])>=-1 and datediff('quarter',[date1],[Order Date])<=0

THEN "show" else "hide" end

apply this in filter and select show.This will show selected quarter and previous quarter.

Thanks

sankar

• ###### 2. Re: How to Calculate the previous quater value...!!

Sankar,

So i can understanding correctly, Date1 will be my parameter..?? and what value it should contain.?

• ###### 3. Re: How to Calculate the previous quater value...!!

Hi Nakul,

Use the date in parameter range.

When we select any date in parameter then it will go with selected quarter and previous quarter.

Thanks

sankar

• ###### 4. Re: How to Calculate the previous quater value...!!

Hi Nakul,

To find the difference two dates in terms of Months, Years, Quarters......, We use the Datediff Function.

datediff( 'level', [Date1], [Date2])

Tableau performs Calculation like Date2 - Date1

EX: 1)

Datediff('day', #21-Jan-2014#, #22-Feb-2014#)

O/P: 32

EX: 2)

Datediff('month', #21-Jan-2014#, #22-Feb-2014#)

O/P: 1

EX: 3)

Datediff('month', #22-Feb-2014#,#21-Jan-2014# )

O/P: -1

In the Above examples, I have have given Dates from our end, You replace it by Field or Parameter.

Best Regards

Laxman Kumar

• ###### 5. Re: How to Calculate the previous quater value...!!

Thanks Sankar,

I tried and its working fine....:)

• ###### 6. Re: How to Calculate the previous quater value...!!

Hi Nakul,

If it works for you then happy. We always help the people.

Refer more things here.

https://public.tableau.com/profile/sankarmagesh#!/vizhome/Selecteddateandprevioussalesdata/Dashboard1

Thanks

sankar

• ###### 7. Re: How to Calculate the previous quater value...!!

Hi Sankar,

I have calcualted QTD Sales using Below ,It's Giving Correct Result.

IF [Date] <=TODAY()

AND DATEDIFF('quarter',[Date],Today())= 0

THEN [Extended Price USD] END

Now i am looking to calculate PY -QTD using below ,But not able to get the required result. Can you please Help..

IF [Date] <=TODAY()

AND DATEDIFF('quarter',[Date]-1,Today())= 0

THEN [Extended Price USD] END

FYI : Our Current FY starts from July 1st 2015.