Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Purushothaman
Partner - Creator III
Partner - Creator III

Expression for: Quarter

Hi there,

I would like to find the below:

1) Previous Quarter for the same Year.

2) Same Quarter for the Last Year.

3) Same Quarter for the Last Last Year.

This is my expression for Max Quarter: 

sum( {$<YEAR = {$(=Max(YEAR))} ,MONTHNO={$(=Max(MONTHNO))}, MONTH= , PERIODDISPLAY= , QUARTER= {$(=MaxString(QUARTER))} , HALFYEAR= >} [VV] )  

Below is my master calendar:

Purushothaman_0-1652173887700.png

Anyone, Please Help!!!

Thank you!!

 

2 Solutions

Accepted Solutions
HugoRomeira_PT
Creator
Creator

Hello,

Try this:

1) Previous Quarter for the same Year

sum( {$<YEAR =  ,MONTHNO=, MONTH= , PERIODDISPLAY= , QUARTER= , HALFYEAR= ,Num={">= $(=Num(QuarterEnd(Max(Date),-1)) ) <=$(=Num(QuarterEnd(Max(Date),-1)))"}>} [VV] )  

2) Same Quarter for the Last Year

sum( {$<YEAR = {$(=Max(YEAR)-1)} ,MONTHNO=, MONTH= , PERIODDISPLAY= , QUARTER= {$(=MaxString(QUARTER))} , HALFYEAR= >} [VV] )  

3) Same Quarter for the Last Last Year

sum( {$<YEAR = {$(=Max(YEAR)-2)} ,MONTHNO=, MONTH= , PERIODDISPLAY= , QUARTER= {$(=MaxString(QUARTER))} , HALFYEAR= >} [VV] )  

Hope it helps.

 

If the issue is solved please mark the answer with Accept as Solution.
If you want to go quickly, go alone. If you want to go far, go together.

View solution in original post

vinieme12
Champion III
Champion III

You can easily base everything on the Date field

 

Current Quarter, same Year

sum( {<Date = {">=$(=Date(Quarterstart(Max(Date)),'DD/MM/YYYY'))<=$(=Date(Quarterend(Max(Date)),'DD/MM/YYYY'))"}>}[VV])

 

Previous Quarter, Same Year

sum( {<Date = {">=$(=Date(Quarterstart(Max(Date),-1),'DD/MM/YYYY'))<=$(=Date(Quarterend(Max(Date),-1),'DD/MM/YYYY'))"}>}[VV])

 

Same Quarter, Last Year

sum( {<Date = {">=$(=Date(Quarterstart(addyears(Max(Date),-1)),'DD/MM/YYYY'))<=$(=Date(Quarterend(addyears(Max(Date),-1)),'DD/MM/YYYY'))"}>}[VV])

 

Same Quarter, Last Last Year

sum( {<Date = {">=$(=Date(Quarterstart(addyears(Max(Date),-2)),'DD/MM/YYYY'))<=$(=Date(Quarterend(addyears(Max(Date),-2)),'DD/MM/YYYY'))"}>}[VV])

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.

View solution in original post

3 Replies
HugoRomeira_PT
Creator
Creator

Hello,

Try this:

1) Previous Quarter for the same Year

sum( {$<YEAR =  ,MONTHNO=, MONTH= , PERIODDISPLAY= , QUARTER= , HALFYEAR= ,Num={">= $(=Num(QuarterEnd(Max(Date),-1)) ) <=$(=Num(QuarterEnd(Max(Date),-1)))"}>} [VV] )  

2) Same Quarter for the Last Year

sum( {$<YEAR = {$(=Max(YEAR)-1)} ,MONTHNO=, MONTH= , PERIODDISPLAY= , QUARTER= {$(=MaxString(QUARTER))} , HALFYEAR= >} [VV] )  

3) Same Quarter for the Last Last Year

sum( {$<YEAR = {$(=Max(YEAR)-2)} ,MONTHNO=, MONTH= , PERIODDISPLAY= , QUARTER= {$(=MaxString(QUARTER))} , HALFYEAR= >} [VV] )  

Hope it helps.

 

If the issue is solved please mark the answer with Accept as Solution.
If you want to go quickly, go alone. If you want to go far, go together.
vinieme12
Champion III
Champion III

You can easily base everything on the Date field

 

Current Quarter, same Year

sum( {<Date = {">=$(=Date(Quarterstart(Max(Date)),'DD/MM/YYYY'))<=$(=Date(Quarterend(Max(Date)),'DD/MM/YYYY'))"}>}[VV])

 

Previous Quarter, Same Year

sum( {<Date = {">=$(=Date(Quarterstart(Max(Date),-1),'DD/MM/YYYY'))<=$(=Date(Quarterend(Max(Date),-1),'DD/MM/YYYY'))"}>}[VV])

 

Same Quarter, Last Year

sum( {<Date = {">=$(=Date(Quarterstart(addyears(Max(Date),-1)),'DD/MM/YYYY'))<=$(=Date(Quarterend(addyears(Max(Date),-1)),'DD/MM/YYYY'))"}>}[VV])

 

Same Quarter, Last Last Year

sum( {<Date = {">=$(=Date(Quarterstart(addyears(Max(Date),-2)),'DD/MM/YYYY'))<=$(=Date(Quarterend(addyears(Max(Date),-2)),'DD/MM/YYYY'))"}>}[VV])

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
Purushothaman
Partner - Creator III
Partner - Creator III
Author

@vinieme12 @HugoRomeira_PT 
Thank you for your help!!!

Much Appreciated!