Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
mishraamit2485
Creator
Creator

Set clear state on a variable

Hi All, Can we set a clear state on a button the action behind that button action behind that button is to select current month out of all the months.

Suppose I'm hitting clear button so this month its should go on Oct next month it should go on Nov.

Currently what is happening it is storing this month(Oct) when i'm setting the clear state where as next month also it is Oct only...i want something where it selects dynamic selection(Oct this month Nove next), instead of static (Stores Oct) only.

23 Replies
Anonymous
Not applicable

then you need to do the following steps

1) provide a short macro: (press strg+M)

Sub DefineClearState
ActiveDocument.SetClearState
End Sub

2) define a Trigger on your sheet with Action run macro and define macro "DefineClearState"

mishraamit2485
Creator
Creator
Author

Here is the dead end , i can not use macro n all....

Anonymous
Not applicable

then try this:

- unselect month, quarter etc.

- use Trigger as mentioned in my Image on open document

- save doc

- when you open it will select latest quarter. if you Change to other quarter and press "clear" the latest quarter will be selected again

mishraamit2485
Creator
Creator
Author

i tried the way you are telling, its going to 2nd qtr only..

Anonymous
Not applicable

curious, when I follow your instructions Step1 and 2 I see quarter 3 after clear button???

upps, not allowed to upload

mishraamit2485
Creator
Creator
Author

How i'm doing do the step 1, set the clear state on max qtr(which is 2 in this case), now follow the step 3 reload the doc, when you open 3rd qtr will be selected now select any month in (4,5,6) hit clear it will go to 2nd qtr only..

I have setup trigger on open max({1}Qtr)

Anonymous
Not applicable

see attached app, when I follow your steps I get correct result

mishraamit2485
Creator
Creator
Author

Strange...where is the attached app?

Anonymous
Not applicable

Hi Amit,

Load a Quarter field with the following script.

'Q'&(FLOOR(NUM(MONTH(date Filed from DB)-1)/3)+1) AS Quarter,

and then in front end On clear Button set action

Select In Field-->Quarter

and in search string give this --> ='Q'&(FLOOR(NUM(MONTH(max(date Filed from DB))-1)/3)+1)

It will select the latest quarter  in Quarter field based on Date field from DB.

mishraamit2485
Creator
Creator
Author

I already have quarter codes there like 2015Q4 and 2016Q1, whit this data value i'm deriving the current qtr and previous qtr from that(using set analysis)..now I have to take max of it?