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

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Default selection

Hi Guys,

I need to select the last two years as default selection. If anybody knows the syntax I would appreciate.

Thanks,

Nima

1 Solution

Accepted Solutions
swuehl
MVP
MVP

If you are talking about default selection, you are talking about setting these values on opening the document or when you enter a sheet, something like that?

You can use actions triggered by some event to achieve what I think you want.

For example, create a button with action Selection - Select in Field.

Then enter

Year

as field name, or however your Year fieldname is (but without equal sign or single quotes, just the name)

and as search expression:

='=sum({<Years = {">$(=max(Years)-2)"}>} 1)'

A click on the button should select last two years, please see attached demo.

If this works, you can use any appropriately triggered action e.g. under document properties -Triggers - OnOpen event, to have this done automatically.

Hope this helps,

Stefan

View solution in original post

4 Replies
swuehl
MVP
MVP

If you are talking about default selection, you are talking about setting these values on opening the document or when you enter a sheet, something like that?

You can use actions triggered by some event to achieve what I think you want.

For example, create a button with action Selection - Select in Field.

Then enter

Year

as field name, or however your Year fieldname is (but without equal sign or single quotes, just the name)

and as search expression:

='=sum({<Years = {">$(=max(Years)-2)"}>} 1)'

A click on the button should select last two years, please see attached demo.

If this works, you can use any appropriately triggered action e.g. under document properties -Triggers - OnOpen event, to have this done automatically.

Hope this helps,

Stefan

Not applicable
Author

Thanks a lot , it works.

Not applicable
Author

Hello Stefan,

I can perfectly adopt your suggestion for a default selection in my application. Thanks!

Although it works, I didn't got through why it works yet. Would you mind explaining what does the "='=" stands for?

Regards,

Thomas

swuehl
MVP
MVP

Thomas,

you need to look out for the second single quote at the very end, it's a string, like

='AdvancedSearchExpressionString'

where the advanced search expression is

=sum(....)

Don't ask me why we need to enclose an advanced search expression in single quotes with a preceding equal sign when used in a selection action. IMHO search expressions are probably the worst documented part of QV I know of.

Regards,

Stefan