Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
snancyiv
Contributor III
Contributor III

Previous Quarter calculation

Hi everyone!

I'm trying to calculate the change in two quarters, I think I'm getting close but not sure what else I am missing in my formula and hoping that someone can help. Basically, user will select a quarter and the KPI will show current value and what the change was from prior quarter. 

Here are the sales figures:

Current Quarter Sales: 356

Previous Quarter Sales: 524

I created two variables to return the start dates, one for current quarter and another for previous quarter:

vCurrentQuarter: date(min([Year Month]),'YYYY-MMM')

vPreviousQuarter: date(addmonths(min([Year Month]),-3),'YYYY-MMM')

Calculation for Previous quarter sales: sum(${<'$(vCurrentQuarter)' ={"$(vPreviousQuarter)"}>} Sales)

The calculation keeps giving me current quarter sales. What am I missing? Thanks in advance!

Labels (2)
11 Replies
krishna_p
Contributor II
Contributor II

Hi, 

don't wry, plz provide me data set files

so, i will calculate accurate answer for you and tell me one thing you have created variables in front-end or back-end.

Here are the sales figures which you want , right ?

Current Quarter Sales: 356

Previous Quarter Sales: 524

snancyiv
Contributor III
Contributor III
Author

Hi, 

data sets attached. The association is on Date to Discharge Date. No variables here. I do have a custom field for quarter:

[Fiscal Year] &'-'&
IF([Fiscal Month]='1','Q1',
IF([Fiscal Month]='2','Q1',
IF([Fiscal Month]='3','Q1',
IF([Fiscal Month]='4','Q2',
IF([Fiscal Month]='5','Q2',
IF([Fiscal Month]='6','Q2',
IF([Fiscal Month]='7','Q3',
IF([Fiscal Month]='8','Q3',
IF([Fiscal Month]='9','Q3',
'Q4'))))))))) AS [YearQuarter]

When you filter on 2022-Q4, it should be:

Current Quarter TotalNumerCase: 107

Previous Quarter TotalNumerCase: 162