Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Macro

Hi,

I'm looking for a macro : when I select a year it selects  selected year and the previous year.

Any idea is appreciated.

Thanks,

1 Solution

Accepted Solutions
MayilVahanan

hi,

     For me, it work correctly.. Can you post a file?

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.

View solution in original post

19 Replies
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Don't us a macro. Use a OnSelect Action for the field (Set in Document Properties Triggers pane).

Use Toggle Select as the action.

For the field value use

=only(Year)-1

-Rob

Not applicable
Author

Thanks Rob,

But I want to select the selected year and previous year at the same time.With Toggle select , it selects only one at a time.

Thanks

MayilVahanan

Hi,

     Try like this,

     Document properties ->Triggers ->Field in event trigger -> Year

     OnSelect ->Action->Select in field

     Field ->Year

     SearchString->  ='(*'&vT1&'*|*'&vT&'*)'

     Where vT1 => Max(Year) and vT => Max(Year)-1

Hope it helps

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
Not applicable
Author

Sorry , it only selects the max(year)-1 ....

Thanks

MayilVahanan

hi,

     For me, it work correctly.. Can you post a file?

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
Not applicable
Author

My mistake, I used toggle select....

Thanks again..

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

...But I want to select the selected year and previous year at the same time.With Toggle select , it selects only one at a time....

When I test with V11, it retains the selection I make and the Toggle Selection adds the prior year. I get both years selected.

-Rob

Not applicable
Author

Here is another problem now!

Let say if I want to select 2 years like 2008 and 2010 , how can I manage it?

Thanks

MayilVahanan

Hi,

        

OnSelect ->Action->Select in field 

     Field ->Year

     SearchString->  ='(*'&vT1&'*|*'&vT&'*)'

     Where vT1 => Max(Year) and vT => Max(Year)-2

 

     or

Do you want to select 2008 and 2010 only, 

     ='(*2008 | 2010*)'

Hope it helps

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.