Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Nick_Meijers
Contributor
Contributor

Qlik Sense Button Order

Hi,

I have some experience in Qlik Sense, so not a total beginner.

I have a field HOLIDAYS_UNIQUE_ACCIDENTS, this is a count of the number of accidents per year on US holidays.
There is a button, if you click it I want it to select the value in the YEAR field that has the lowest number of accidents.
If you click it again, I want it to select the value in the YEAR field that has the highest  number of accidents.

I have set a variable, not very original (neither is the name):
set vToggleTopBottom2 = 1;

My button has 3 actions:
1. Clear all selections

2. Set variable value:
Variable 'vToggleTopBottom2 '
Value =if(vToggleTopBottom2 = 1, -1, 1)

3. Select values in a field
=Aggr(If(Rank(HOLIDAYS_UNIQUE_ACCIDENTS * $(vToggleTopBottom2)) = 1, YEAR), YEAR)

Each on their own they do what they need to do.

But in the order stated above:
Depending on the starting state of the variable, it shows me 2004 (year with highest count) or 2014 (year with lowest count).

But it keeps showing the same value when pressing the button.
Only when you manually clear the filter, does it toggle (once) to the other value).

This leads to me to think the order of the actions does not necessarily translate to the order of execution of actions.

I have tried switching the actions every which way, but to no avail.
One note on that though:
If I put the clear action as the last action, I do for a moment see the values switch between 2004 and 2014, which makes it all the more frustrating.

 

Labels (2)
2 Replies
rnorris
Partner - Creator
Partner - Creator

Hey, so for whatever mad reason, button actions are all completed 'simultaneously', or rather, they are multi threaded, so there's no way to know the order they will trigger. I've not found a way round it. 

Ahidhar
Creator III
Creator III

something like this ?