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

Announcements
Qlik Connect 2026! Turn data into bold moves, April 13 -15: Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
terezagr
Partner - Creator III
Partner - Creator III

On/Off button - when clicked on Clear On button does not go back to Off

Hi all,

I have been working on a project where using On/Off button to apply set filters. The button works perfectly, but problem starts when I click on Clear in the top menu...despite the fact that all selections are cleared, the button stays ON, but it should go back on OFF.

Please let me know if you have any solution for this.

Regards,

Tereza

1 Solution

Accepted Solutions
offjunior
Creator
Creator

Good night!

I created a new button in your application that does what you need. I used the function GETCURRENTSELECTION () and seemed to work right. Check and reply me if that was what you wanted, if not reply me what is wrong with this working solution.

Attached hereto qvw your document.

Hug!

View solution in original post

13 Replies
israrkhan
Specialist II
Specialist II

Hi ,

I think variable can not be clear,

but an idea is use a button to clear all with action "Clear All", and add another action to same button, that will be

"Set Variable" in set variable change the value to off or 0, try it, but i am not sure...

like

Button Actions:

Clear All

Set Variable

Not applicable

Could you please upload a QVW file showing the button ?

If not, please provide details of the button insights..

You may be able to solve this problem using a variable in order to control de button On/Off sequence..

terezagr
Partner - Creator III
Partner - Creator III
Author

Hi,

I have clear selection button - where Clear All is applied...and it still does not change the ON button to OFF.

terezagr
Partner - Creator III
Partner - Creator III
Author

Hi Luis,

for the ON button

Apply Bookmark - bookmarkA

Set Variable - if(vOnOffButton='Show','Hide','Show')

for the OFF button:

Apply Bookmark - bookmarkB

Set Variable - if(vOnOffButton='Show','Hide','Show')

Thanks for help.

Not applicable

Hi Tereza,

See attached example.

I´ve just changed the visibility condition.

terezagr
Partner - Creator III
Partner - Creator III
Author

Hi Luis,

unfortunately your solution does not work too....when you click on the button and the selection is made the button shows on, but then when you click on Clear all, the button should go back to state OFF...but it stays ON.

I would like to find a solution for this as it could be quite confusing for users to see that a button is still ON, despite the fact there is no selection made.

p_verkooijen
Partner - Specialist II
Partner - Specialist II

Tereza,

The default Clear all has no effect on variables, only dimensions.

use a button with actions

  1. Clear All
  2. Set Variable vOnOffButton = 0


Also changed the On / Off button to IF(vOnOffButton=1, 'Off', 'On') instead of show conditionals

flipside
Partner - Specialist II
Partner - Specialist II

Hi Tereza,

One solution could be to link the button status to a field. For example, create a table like this in your script ...

Button:

Load * inline [
Status
1]
;

Your button text may be something like this ..

=

if(GetSelectedCount(Status)=1,'On','Off')

And one of your button actions needs to select the value 1 in the field Status. When you click clear it will reset the button text.

Hope this helps

flipside


p_verkooijen
Partner - Specialist II
Partner - Specialist II

flipside's solution could work better than my suggestion, end users can use the standard clear all functionality


Also change the variable vOnOffButton to : if(GetFieldSelections(Status)=1,1,0)