Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Sameer9585
Creator II
Creator II

Current vs Previous Quarter

Hi, 

I am trying to calculate the current vs previous Quarter sales means if I select date 3/1/2019 it is 1st march that is Q1 of 2019 year.It should display the comparison of  sales for the Q4 of 2018 year and Q1 of 2019 year in one chart.I will provide the file that I used below.The sheet is sheet3  that the problem to be solved on.

Thanking You in advance,

1 Solution

Accepted Solutions
dplr-rn
Partner - Master III
Partner - Master III

Few Steps
1- create a master calendar if you dont have one
https://qlikviewcookbook.com/2015/05/better-calendar-scripts/

2- add a column to your master calendar for quarter year 

e.g. 

'Q' & ceil(month(TempDate) / 3)&'-' & Year(TempDate) AS QuarterYear,

3 - 2 variables to identify current quarter and previous quarter

e.g.

vCurrentQuarter = 'Q' & ceil(month(today()) / 3)&'-' & Year(today())

vPreviousQuarter = 'Q' & ceil(month(addMonths(today(),-3)) / 3)&'-' & Year(addMonths(today(),-3))

4- use the variables in your expressions

e.g.

sum({<QuarterYear={$(vCurrentQuarter)}>}Sales)

sum({<QuarterYear={$(vPreviousQuarter)}>}Sales)

View solution in original post

2 Replies
dplr-rn
Partner - Master III
Partner - Master III

Few Steps
1- create a master calendar if you dont have one
https://qlikviewcookbook.com/2015/05/better-calendar-scripts/

2- add a column to your master calendar for quarter year 

e.g. 

'Q' & ceil(month(TempDate) / 3)&'-' & Year(TempDate) AS QuarterYear,

3 - 2 variables to identify current quarter and previous quarter

e.g.

vCurrentQuarter = 'Q' & ceil(month(today()) / 3)&'-' & Year(today())

vPreviousQuarter = 'Q' & ceil(month(addMonths(today(),-3)) / 3)&'-' & Year(addMonths(today(),-3))

4- use the variables in your expressions

e.g.

sum({<QuarterYear={$(vCurrentQuarter)}>}Sales)

sum({<QuarterYear={$(vPreviousQuarter)}>}Sales)

guster999
Creator
Creator

Thanks for the clear steps to follow 😀

Just a note that to get this accepted in fx screen - I had to use my variable as such in my chart set analysis:

QuarterYear={'$(=vPreviousQuarter)'}

ie extra quotes and equals sign.

But then it worked perfectly.

cheers

Gus