Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How to replace the current month variable with any month I select?

I have a variable vCurrentMonth which on reload loads the current month.

I have a list box with that last 6 months displayed.  I would like the vCurrentMonth variable to swap out the current month with the one I select. 

So for instance if February is the current month and I select December.  December now becomes the current month. 

Thanks for your help.

1 Solution

Accepted Solutions
Not applicable
Author

Hi Darrin,

You can set a trigger on Field change action, and in this set the variable value as GetFieldSelections(Month) or Only(Month) or Max(Month).

Document Properties - > Triggers -> On Fields list, select the month field and then set the action.

Print3.PNG.png

Print4.PNG.png

Tell me if you have any problem.

Regards.

View solution in original post

4 Replies
Not applicable
Author

Hi Darrin,

You can set a trigger on Field change action, and in this set the variable value as GetFieldSelections(Month) or Only(Month) or Max(Month).

Document Properties - > Triggers -> On Fields list, select the month field and then set the action.

Print3.PNG.png

Print4.PNG.png

Tell me if you have any problem.

Regards.

Not applicable
Author

And if you are thinking in select more than one value for the months and you want to save all values in the variable, you can use Concat(GetFieldSelections(F1), '|').

The second parameters is a split character between values.

Regards.

Anonymous
Not applicable
Author

Thanks Guzman, that worked great.  But one thing broke.

I have a second variable for the vPrevMonth to store the prior month which I have now set a second action on max(F1) -1

I have numbers for the months from the start of our calendar so -1 will always work and it does.

This month is 50 and my variable, when I click on Feb, does make the vPrevMonth = 49.

But it seems that my set analysis using the vPrevMonth does not work any longer.  My fear is that when I select my month it now has the month as the current selection and thus drops the prior month I wish to display as well.

In a nutshell I want to take this further where when a month is selected, the previous changes and is not limited by the selection.

I hope that makes sense.

Thanks

tresesco
MVP
MVP

If you want previous as well as the current month data, try something like:

Sum( {<Month={$(vCurrentMonth), $(vPrevMonth)}>} Amount)

Edit:

For only previous month:

Sum( {<Month={$(vPrevMonth)}>} Amount)

If you want to disregard a field's selection then like:

Sum( {<FieldNameTobeDisregarded=,Month={$(vPrevMonth)}>} Amount)

To disregard all selections:

Sum( {1<Month={$(vPrevMonth)}>} Amount)