Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
kokeeffe
New Contributor II

Current and Previous Quarter calculations

Hi all,

I am creating a Quarter field with the following script:

'Q' & ceil(right([Acc_Calendar.Acc Period],2)/3) as Quarter   

How do i then create a vCurrentQuarter and vPreviousQuarter ?

Thanks in advance    

7 Replies
effinty2112
Honored Contributor

Re: Current and Previous Quarter calculations

Hi Kieron,

                    Consider a separate numeric QuarterID field such as

ceil(right([Acc_Calendar.Acc Period],2)/3)  as QuarterID

or you can try defining your quarter as a Dual:

Dual('Q' & ceil(right([Acc_Calendar.Acc Period],2)/3) , ceil(right([Acc_Calendar.Acc Period],2)/3) ) as Quarter

Cheers

Andrew

kokeeffe
New Contributor II

Re: Current and Previous Quarter calculations

Thanks Andrew,

That gives me a numeric value for each quarter, what is the logic then to get current quarter (or previous quarter). To get Current week i have used: let vCurrent_week = num(week(today()), '00');

To get current year week i have used: let vCurrent_yearweek = weekyear(today()) & num(week(today()), '00');

But i'm confused about current quarter.

Thanks,

Kieron

effinty2112
Honored Contributor

Re: Current and Previous Quarter calculations

Hi Keiron,

In the UI $(=max(QuarterID)) will give the current QuarterID according to the selections and $(=-1+max(QuarterID)) will give the previous.


Cheers


Andrew

lakkydev
Contributor II

Re: Current and Previous Quarter calculations

You can try below one

vCurrent_Quarter=   Year={"$(=GetFieldSelections(Quarter))"}

vPrevious_Quarter = Year={"$(=GetFieldSelections(Quarter)-1)"}

sum({<$(=vCurrent_Quarterr)>}Sales)

sum({<$(=vvPrevious_Quarter)>}Sales)

lakkydev
Contributor II

Re: Current and Previous Quarter calculations

You can try below one

vCurrent_Quarter=   Quarter={"$(=GetFieldSelections(Quarter))"}

vPrevious_Quarter = Quarter={"$(=GetFieldSelections(Quarter)-1)"}

sum({<$(=vCurrent_Quarterr)>}Sales)

sum({<$(=vvPrevious_Quarter)>}Sales)

kokeeffe
New Contributor II

Re: Current and Previous Quarter calculations

Hi devendarlakkyreddy‌ where should i try create those? in the script editor or in my calculation ?

Thanks,

Kieron

lakkydev
Contributor II

Re: Current and Previous Quarter calculations

by using Quarter field in the front end create a variable , then use calculation in the chart

Community Browser