Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I have a script that is loading data into a chart in Qliksense.
In my chart I have a filter pane where I am selecting Year (file name MI_YEAR) and Period (Field name MI_PERIOD).
The chart is showing the correct data.
What I want to do now is store my selected values for MI_YEAR and MI_PERIOD in variables.
I have created a new variable called vSelect_Year with the expression of
= GetFieldSelections(MI_YEAR,'","')
When I try to add this variable to my chart it is showing as NULL.
If the selection is MI_YEAR = 2023 and MI_PERIOD = 05 I want these values stored into my varaibles so that I use them in calculations in my chart (i.e. to determine the previous year/period 2023 / 04).
You couldn't store a previous selection within a variable because it's evaluated by each selection. Beside this you may struggle with the syntax by creating and calling the variables which needs to be always done in the context which kind of data are stored and where they are used.
However you don't need variables for this kind of task else you could apply this as set analysis conditions within the expressions, for example with:
sum({< Period = {"$(=max(Period))"}>} Value)
returning the results for the selected Period respectively to the max. possible Period if none is selected. With:
sum({< Period = {"$(=max(Period)-1)"}>} Value)
you will get the the results from the previous Period.
The field Period must not be shown in the UI else selecting per Year and Month will work for it - if this field is related to them within the calendar and there created per: Year * 12 + Month. That's not mandatory necessary but it simplifies the matter to use a single field for it which will also work over the years.
=Concat(DISTINCTMI_YEAR,',')
I think you might have misunderstood what I am trying to do.
I am trying to save the value from my filter pane into a variable. Concat is a string function for joining strings.
Or am I missing something with CONCAT ??
You couldn't store a previous selection within a variable because it's evaluated by each selection. Beside this you may struggle with the syntax by creating and calling the variables which needs to be always done in the context which kind of data are stored and where they are used.
However you don't need variables for this kind of task else you could apply this as set analysis conditions within the expressions, for example with:
sum({< Period = {"$(=max(Period))"}>} Value)
returning the results for the selected Period respectively to the max. possible Period if none is selected. With:
sum({< Period = {"$(=max(Period)-1)"}>} Value)
you will get the the results from the previous Period.
The field Period must not be shown in the UI else selecting per Year and Month will work for it - if this field is related to them within the calendar and there created per: Year * 12 + Month. That's not mandatory necessary but it simplifies the matter to use a single field for it which will also work over the years.