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

Announcements
Join us in Toronto Sept 9th 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
hopkinsc
Partner - Specialist III
Partner - Specialist III
Author

no, the only thing that set the variable are 5 date button. but obviously when clearing the selections these dates are cleared also (which is correct). nothing else sets the variable value.

it works perfectly if i remove the BranchView selection, but i need this selected always.

flipside
Partner - Specialist II
Partner - Specialist II

Try this ...

=if(

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

Or perhaps if you can upload an example, maybe there's a better way!

flipside

hopkinsc
Partner - Specialist III
Partner - Specialist III
Author

hi flipside,

I have attached a quick sample..

i have set a clear state so when clear is clicked it selects 'BranchView = Branch'

there is a variable called vDateRange

the buttons set the variable and make a date selection, and the button colours are calculated based on the variable value.

Any more help would be greatly appreciated

flipside
Partner - Specialist II
Partner - Specialist II

Must be the Clear State causing it to do this - I have never used this option!

Not sure of a way around it at the moment, but if I think of something I'll post a reply.

flipside
Partner - Specialist II
Partner - Specialist II

OK, forget the triggers - too complicated. try these expressions for your button colours ...

=if(vDateRange='YTD' and not(Trim(Replace(Replace('BranchView: ' & GetFieldSelections(BranchView),GetCurrentSelections(),''),'BranchView:',''))=''),RGB(255,0,0), RGB(0,0,255))

=if(vDateRange='MTD' and not(Trim(Replace(Replace('BranchView: ' & GetFieldSelections(BranchView),GetCurrentSelections(),''),'BranchView:',''))=''),RGB(255,0,0), RGB(0,0,255))

flipside

hopkinsc
Partner - Specialist III
Partner - Specialist III
Author

Hi,

I actually got this working by resetting the clear state, adding a list box for the BranchView field, then in the properties of that list box i ticked 'Always one Selected Value'. Deleted the list box.

That gave the same result as using the 'Set Clear State' option.

Then i used your solution above..

=if(

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

Which did the trick

Thanks for your help!