Qlik Community

App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

Announcements
QLIKWORLD LIVE! MAY 16 - 19TH, EARLY BIRD DISCOUNTS! REGISTER TODAY
cancel
Showing results for 
Search instead for 
Did you mean: 
fishnumber2
Contributor II
Contributor II

SOLVED Create variables for each unique value in a field

I'm trying to create a variable for each quarter ([Incident Quarter]) in a table (Incidents). For example, the most recent quarter would be $curr_Quarter, the previous quarter would be $curr_Quarter_min1, and $curr_Quarter_min2, etc. Any suggestions are welcomed. Thanks in advance!

1 Solution

Accepted Solutions
stevejoyce
Specialist II
Specialist II

Well how would you expect to use an unknown ("dynamic") number of variables?

I didn't understand how you were planning on using the variable in a table...

 

But yes that would work like you said with the loop.  BTW, for consistency and reusability if you do it, max([Incident Quarter], 1) //max quarter can be used (no parameter defaults to 1)

View solution in original post

4 Replies
stevejoyce
Specialist II
Specialist II

You can leverage the 2nd parameter in max function

=max([Incident Quarter]) //max quarter

=max(Incident Quarter], 2) //second max incident

etc.

fishnumber2
Contributor II
Contributor II
Author

Thanks @stevejoyce . I think that'll help me get more than half way there! The number of quarters in the data set can vary so I want to keep the number of variables that I create dynamic. Would I need to first get the number of unique values, and write a loop to create the variables with the max function?

stevejoyce
Specialist II
Specialist II

Well how would you expect to use an unknown ("dynamic") number of variables?

I didn't understand how you were planning on using the variable in a table...

 

But yes that would work like you said with the loop.  BTW, for consistency and reusability if you do it, max([Incident Quarter], 1) //max quarter can be used (no parameter defaults to 1)

fishnumber2
Contributor II
Contributor II
Author

Thank you, worked!