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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
itchel
Contributor
Contributor

Using set analysis to get a value of previous period

Hi. I have a dataset with the fields: Account_id, account_score, year_quarter, YearQuarterKey (which is a running sequencial number for every year-quarter combination). I want to use set analysis in a table presentation on my app, and to add the field previous_quarter_score to every row ! in the table, according the field YearQuarterKey

I tried:

=max( {< YearQuarterKey = {"$(=(YearQuarterKey-1))"} >} account_score)

It did not work.

Any thoughts on how to accomplish this?

Thanks

Labels (1)
1 Reply
whiteymcaces
Partner - Creator
Partner - Creator

The easiest way is to create 2 variables. 1 to store to maximum possible [YearQuarterKey] and the other to store the previous [YearQuarterKey]. These variables will change based on selections made in the App. You can name the variables what ever you like, I'm just showing an example.

1. YrQtrKy = Max(YearQuarterKey)

2. PrevQtrKy = YrQtrKy - 1

Then, in your chart you should create 2 Expressions, 1 for this Quarter's Score, and 2 for Last Quarter's Score. [Account_id] should be one of the dimensions.

1. Sum({<YearQuarterKey = {$(YrQtrKy )}>} Score)

2. Sum({<YearQuarterKey = {$(PrevQtrKy )}>} Score)