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

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Button for value-selection only when nothing is selected already

Hello,

in my QV-App I want to use a button to select some field values. In one field (called LS_BEST_MONAT), a new selection should only be made when there is nothing selected yet.

I have a listbox for that field, it contains year-month values like:

2013-10

2013-11

2013-12

2014-01

...

There are also NULL-Values ( - ) possible.

When there is no selection in this field, pressing the button should select previous month.

This is my code for the button-action 'Select in field [LS_BEST_MONAT]':

=if(GetSelectedCount(LS_BEST_MONAT)=0,

  Year(AddMonths(Now(),-1))&'-'&num(Month(AddMonths(Now(),-1)),'00')

  )

This works when there were no slections on that field before pressing the button.

But IF there were selections before, after pressing the button the NULL-Values of this field are selected. But in this case, I don't want the previous selection to change, it should stay as it is.

I tried to add else-condition:

=if(GetSelectedCount(LS_BEST_MONAT)=0,

  Year(AddMonths(Now(),-1))&'-'&num(Month(AddMonths(Now(),-1)),'00')

,GetFieldSelections( LS_BEST_MONAT)

  )

But with this the previous selection simply gets de-selected, so that nothing is selected for this field anymore.

Can somebody help?

1 Solution

Accepted Solutions
Nicole-Smith

Change your Select in Field properties as follows:

Field:

=if(GetSelectedCount(LS_BEST_MONAT)=0, 'LS_BEST_MONAT')

Search String:

=Year(AddMonths(Now(),-1))&'-'&num(Month(AddMonths(Now(),-1)),'00')

View solution in original post

4 Replies
tresesco
MVP
MVP

If you want the previous selection to be intact and the new ones as additional, try 'Toggle Select' in action.

Edit: Or, for your case try using an additional trigger 'Clear Field' for the same button above the existing one.

Nicole-Smith

Change your Select in Field properties as follows:

Field:

=if(GetSelectedCount(LS_BEST_MONAT)=0, 'LS_BEST_MONAT')

Search String:

=Year(AddMonths(Now(),-1))&'-'&num(Month(AddMonths(Now(),-1)),'00')

Not applicable
Author

This works perfect, thank you!

Nicole-Smith

I'm glad it works for you