Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
kishoreravi1983
Contributor III
Contributor III

Get Previous Quarter

Hi Guys,

Please help me to get Previous Quarter if i have data has below.

TYQUARTER

2015-Q1
2015-Q2
2015-Q3
2015-Q4
2016-Q1
2016-Q2
2016-Q3
2016-Q4
2017-Q1
2017-Q2

=Subfield(MaxString(TYQUARTER),'-',2) --> With this i get max Quarter, but i would also need Previous Quarter.

Please through some views on this how to go about it.

Regards,

Ravi

1 Solution

Accepted Solutions
sunny_talwar

I would suggest using The As-Of Table‌ or creating a numeric field which can be used to go back a quarter... may be something like this

LOAD TYQUARTER,

           AutoNumber(TYQUARTER) as QuarterNum

Resident ....

Order By TYQUARTER;

and then you can use this for prev. quarter

{<QuarterNum = {"$(=Max(QuarterNum) - 1)"}>}

View solution in original post

5 Replies
sunny_talwar

I would suggest using The As-Of Table‌ or creating a numeric field which can be used to go back a quarter... may be something like this

LOAD TYQUARTER,

           AutoNumber(TYQUARTER) as QuarterNum

Resident ....

Order By TYQUARTER;

and then you can use this for prev. quarter

{<QuarterNum = {"$(=Max(QuarterNum) - 1)"}>}

kishoreravi1983
Contributor III
Contributor III
Author

Hi Sunny,

Thanks for the Reply. I am able to derive the Previous Quarter but not exactly what i was looking.

Plz have a look at below image.I am looking for last column calculation.

!PQuarter.PNG

sunny_talwar

Images don't really help Ravi... can you share your app and point out what isn't working? Also, it would be helpful if you can mention what your desired output is.

Best,

Sunny

kishoreravi1983
Contributor III
Contributor III
Author

Hi Sunny,

This is what i am looking for.

  

2017 -Q2
MAX Quarter Always - Present Quarter
2016-Q2 Corresponding Quarter of Previous Year from the above
2017-Q1 Also need last Quarter (Max Quarter - 1)
Y/Y %2017Q2-2016Q2/2016Q2
Q/Q %2017Q2-2017Q1/2017Q1

I have data some thing like this..All these are string columns.

   

TYYEARTYMONTHTYQUARTER
FY2014FY2016-012015-Q1
FY2015FY2016-022015-Q2
FY2016FY2016-032015-Q3
FY2017FY2015-012015-Q4

TO GET Subsequent Quarter of Previous Year

=(SubField( MaxString(TYQUARTER),'-',1)-1) & '-' & SubField( MaxString(TYQUARTER),'-',2)

Max Quarter

=MaxString(TYQUARTER) 

=(SubField( MaxString(TYQUARTER),'-',1)-1) & '-' & SubField( MaxString(TYQUARTER),'-',2)

I am stuck to get the previous quarter based on my Max Quarter.

If Q2 2017 is Present - Q1 2017 Previous

IF Q3 2017- Present - Q2 2017 Previous

IF Q1 2017 Present - Q4 2016 Previous

Please help me!

Regards,

Ravi

kishoreravi1983
Contributor III
Contributor III
Author

This is what i am looking for.

 

2017 -Q2 MAX Quarter Always - Present Quarter
2016-Q2Corresponding Quarter of Previous Year from the above
2017-Q1Also need last Quarter (Max Quarter - 1)
Y/Y %2017Q2-2016Q2/2016Q2
Q/Q %2017Q2-2017Q1/2017Q1

I have data some thing like this..All these are string columns.

  

TYYEARTYMONTHTYQUARTER
FY2014FY2016-012015-Q1
FY2015FY2016-022015-Q2
FY2016FY2016-032015-Q3
FY2017FY2015-012015-Q4

TO GET Subsequent Quarter of Previous Year

=(SubField( MaxString(TYQUARTER),'-',1)-1) & '-' & SubField( MaxString(TYQUARTER),'-',2)

Max Quarter

=MaxString(TYQUARTER)

=(SubField( MaxString(TYQUARTER),'-',1)-1) & '-' & SubField( MaxString(TYQUARTER),'-',2)

I am stuck to get the previous quarter based on my Max Quarter.

If Q2 2017 is Present - Q1 2017 Previous

IF Q3 2017- Present - Q2 2017 Previous

IF Q1 2017 Present - Q4 2016 Previous

Please help me!

Regards,

Ravi