Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

soniasweety
Valued Contributor III

get two always

Hi all,

 

 @sunny_talwar

i have a field like  quarter  with values  like  2018Q1,2018Q2,2018Q3,2018Q4,2019Q1

so whenever i open the dashboard i need to see latest two quarters as selected.

how to achive this?

output: 2018Q4,2019Q1  [   if 2019Q2 in the data  the result will be  2019Q1 and 2019Q2]  like dynamic latest two quarters

 

Thanks

Labels (1)
20 Replies
pradosh_thakur
Honored Contributor II

Re: get two always

documrnt settings -> trigers-> on open -> select in field ->

 

lets assume string is the field.

=MaxString({<string=-{"$(=maxstring(string))"}>}string)    // this will give the second max string

=maxstring(string)    / this will give the max string

Learning never stops.
soniasweety
Valued Contributor III

Re: get two always

giving error in expression.
soniasweety
Valued Contributor III

Re: get two always

atatching sample

pradosh_thakur
Honored Contributor II

Re: get two always


@soniasweety wrote:
giving error in expression.

Well if your Quarters are string values this should work just fine. Did you change the field string to your quarter field? Can you please write your final expression here. I dont have the qlik license so would not be able to open it.

Learning never stops.
soniasweety
Valued Contributor III

Re: get two always

your expression is taking the second higest quarter 😞 but i dont want that

i want latest two quarters that means 2018Q4 and 2019Q1 these are the latest two quarters to be selected in listbox by on open
pradosh_thakur
Honored Contributor II

Re: get two always

Isn't 2018Q4 the second highest quarter?  do you have future quarter listed as well?

Learning never stops.
soniasweety
Valued Contributor III

Re: get two always

yes.

currently  2019Q1 is the max quarter  2018Q4 is the second max quarter.

 

so latest two quarters 2019Q1 and 2018Q4 to be selected.

pradosh_thakur
Honored Contributor II

Re: get two always

 

=MaxString({<string=-{"$(=maxstring(string))"}>}string)    // this will give the second max string

=maxstring(string)    / this will give the max string

the above will do if you want the max and second max quarter

 

for latest and second latest you can try

=year(today()) & 'Q' & ceil(month(today())/3)

=year(ADDMONTHS(today(),-3)) & 'Q' & ceil(month(ADDMONTHS(today(),-3))/3)

Learning never stops.
soniasweety
Valued Contributor III

Re: get two always

thank you. but still its not working.

i need an single expression two select latest two quarters from the data
my data looks like below
Quarter
2018Q1
2018Q2
2018Q3
2018Q4 so now when i open the qlikview in listbox 2018Q3,2018Q4 should be selected.
for example 2019Q1 is added now the result should be 2018Q4 and 2019Q1
could you please attach your sample that you have tried?