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

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
hopkinsc
Partner - Specialist III
Partner - Specialist III

Set variable when clearing selections

Hi,

I was wondering if there is a way to change a variable when the CLEAR button is clicked?

I have some date buttons that change colour when selected. they are blue but when one is clicked it changes to red (just so the user can see which date selection is active). When i clear selections the button still stays red.

Can anyone help me please?

Thanks

15 Replies
marcus_sommer

You can request your selections in variables e.g. with GetFieldSelections(), GetSelectedCount() or GetCurrentSelections().

- Marcus

hopkinsc
Partner - Specialist III
Partner - Specialist III
Author

Hi Marcus,

Thanks for your reply, but i don't know what you mean..

I want to change a variable value when the clear selections button is clicked.

If a user selects the 'Month to Date' button, this changes a vDateSelection variable to MTD which then turns the button RED.

When the clear selections button is clicked the variable obviously still reads MTD which means the button is still red.

I want to remove the MTD value from the variable.

Does that make sense?

flipside
Partner - Specialist II
Partner - Specialist II

You can use a Document Event Trigger (OnAnySelect) and add a Set Variable action for a variable with the following value  ...

=if(IsNull(GetCurrentSelections()),'',1)

flipside

hopkinsc
Partner - Specialist III
Partner - Specialist III
Author

Hi Flipside,

Thanks thats what i wanted, the only thing is...

I always have a selection on a field called (BranchView), how would i add this to the formula you gave.

So the current selections will never be empty, there will always be a vlue in 'BranchView'

thanks

marcus_sommer

If you want not clear all fields, you can use GetFieldSelections() or GetSelectedCount()  - probably in combines - in the way how flipside suggested.

- Marcus

flipside
Partner - Specialist II
Partner - Specialist II

This might work (based in this case on a field called 'Region') ...

=if(

    Trim(Replace('Region: ' & GetFieldSelections(Region),GetCurrentSelections(),''))='','',1)

... or if the field can be unselected you might need ...

=if(

    Trim(Replace(Replace('Region: ' & GetFieldSelections(Region),GetCurrentSelections(),''),'Region:',''))='','',1)

flipside

hopkinsc
Partner - Specialist III
Partner - Specialist III
Author

hi Flipside,

i have tried this ..

=if(

    Trim(Replace('BranchView: ' & GetFieldSelections(BranchView),GetCurrentSelections(),''))='','',1)

but it doesnt seem to work unless all selections are cleared.

do you have any ideas?

marcus_sommer

Put the formula in a textbox and look on the result - perhaps any sign is left (CRLF).

flipside
Partner - Specialist II
Partner - Specialist II

Hmm, bit of a tricky one - have you got anything else setting the same variable based on selections?