Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
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.
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.
It works!
Thank you.