Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
lain_
Contributor III
Contributor III

How can I limit selections in a listbox to only and always have exactly two selections?

Exactly as the question above states. For more information, the values in the list box are years and the purpose is to do a calculation between two years so I always need exactly two years selected in the listbox.

1 Solution

Accepted Solutions
chrismarlow
Specialist II
Specialist II

In the toy app I sent, replace the hard coding with something like;

data_dates_temp:
Load distinct
	Date as D1
Resident data_date;

join (data_dates_temp)
Load 
	D1 AS D2
Resident data_dates_temp;

load 
	D2&'/'&Right(D1,2) AS Dates,
	D2 AS Date
Resident data_dates_temp
Where D1>D2;

load 
	D1&'/'&Right(D2,2) AS Dates,
	D2 AS Date
Resident data_dates_temp
Where D2>D1;

DROP Table data_dates_temp;

 

View solution in original post

5 Replies
chrismarlow
Specialist II
Specialist II

Hi,

If you can change the data model then possibly you could try adding a new table/field that gives combinations of the years that then links through to the dates, you could then use 'Always One Selected Value' on that field, something like the below;

20200730_2.png

Otherwise I think you might have to try to do something on the field event triggers possibly involving using macros ... which I think would be clunky.

Cheers,

Chris.

lain_
Contributor III
Contributor III
Author

Could you link your qvw on how to do that? Thank you.

chrismarlow
Specialist II
Specialist II

I've been very lazy and hard coded the date pairs. You could do it dynamically, would depend how many date pairs you have & if you would want them to change (without going & adding in).

lain_
Contributor III
Contributor III
Author

How would it be done dynamically?

chrismarlow
Specialist II
Specialist II

In the toy app I sent, replace the hard coding with something like;

data_dates_temp:
Load distinct
	Date as D1
Resident data_date;

join (data_dates_temp)
Load 
	D1 AS D2
Resident data_dates_temp;

load 
	D2&'/'&Right(D1,2) AS Dates,
	D2 AS Date
Resident data_dates_temp
Where D1>D2;

load 
	D1&'/'&Right(D2,2) AS Dates,
	D2 AS Date
Resident data_dates_temp
Where D2>D1;

DROP Table data_dates_temp;