Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Thomas23
Contributor II
Contributor II

Variable alternate state

Hi,

in my app I try to use variables and alternate states.

I have a filter bar with the field 'year' and a variable vYear. The variable is set by '= year'.

There is also a Text & image Chart that shows me the value of the variable.

I also have an alternate state 'MyState' and the default state of course.

When the filter bar and the text field are assigned to the default state, the text field shows me the value of vYear.
Also when I change the filter the text box shows the correct changed variable.
When I assign the filter bar and the text box to 'MyState' the text box shows the old value of the variable.

 

I searched the internet and only found this post for Qlik View: https://community.qlik.com/t5/QlikView-App-Dev/Variables-alternate-state/m-p/810361

 

Can't variables be assigned to alternate states in Qlik Sense either?



Thank you,

Thomas

Labels (1)
1 Solution

Accepted Solutions
oskartoivonen
Partner - Contributor III
Partner - Contributor III

Variables themselves can't be assigned to a different state as far as I'm aware, but aggregations can. If your variable is set to "=year", it's important to understand that qlik defaults to the Only() aggregation if none other is specified. Thus, your variable is actually set to "=Only(Year)", which is equivalent to "=Only({$} Year)", where $ equals the default state. So, if you want your variable to contain the year value of 'MyState', you need to set your variable as "=Only({MyState} Year)", and it should follow the year-field from the alternative state.

View solution in original post

2 Replies
oskartoivonen
Partner - Contributor III
Partner - Contributor III

Variables themselves can't be assigned to a different state as far as I'm aware, but aggregations can. If your variable is set to "=year", it's important to understand that qlik defaults to the Only() aggregation if none other is specified. Thus, your variable is actually set to "=Only(Year)", which is equivalent to "=Only({$} Year)", where $ equals the default state. So, if you want your variable to contain the year value of 'MyState', you need to set your variable as "=Only({MyState} Year)", and it should follow the year-field from the alternative state.

Thomas23
Contributor II
Contributor II
Author

It works!
Thank you.