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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Macro to select value in variable

Hy everybody,

I have a application where I need a botton that selects the last X minutes (in the example bellow I'll use 15 minutes).

I've tried something like that:


Variable =>
time1 = =date((LocalTime() - 0.010416), 'DD/MM/YYYY hh:mm:ss') ==> returns the last 15 minutes
Macro=>

sub last
set x= ActiveDocument.Fields("Opening_Date")

WHILE y = (Opening_Date >= time1)
x.toggleselect y

WEND


end sub


The macro says that is ok, but nothing is selected.

Any suggestions?

Thanks,

Leandra Scordamaglia

1 Solution

Accepted Solutions
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

For version 9, try using Actions instead of a macro. In the button add action 'Select in Field'. Set the Field value to Opening_Date. For the search string use:

='>' & timestamp(now(1) - MakeTime(0,15,0))

Note I'm assuming "Opening_Date" is a real timestamp. You may have to adjust somewhat to make the select string format match your data format.

See attached qvw for working example.

-Rob

View solution in original post

6 Replies
fernandotoledo
Partner - Specialist
Partner - Specialist

When this variable is created? If it´s in the script it should work, if not, you should use the EVALUATE function in the macro to calculate that expression´s result and use that in the selection command.

Anonymous
Not applicable
Author

Fernando,

The variable is not in the script because if it was there it wouldn't represent the last 15 minutes, it would be the last 15 minutes from the last reload, right?

Could you give an example how to use the EVALUATE function?

Thanks,

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Leandra, what version of QV?

-Rob

Anonymous
Not applicable
Author

QV 9

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

For version 9, try using Actions instead of a macro. In the button add action 'Select in Field'. Set the Field value to Opening_Date. For the search string use:

='>' & timestamp(now(1) - MakeTime(0,15,0))

Note I'm assuming "Opening_Date" is a real timestamp. You may have to adjust somewhat to make the select string format match your data format.

See attached qvw for working example.

-Rob

Anonymous
Not applicable
Author

Hey, Rob.

Thanks very much for your answer and suggestion.

We'll try it in my data model.

Once again, thanks.

Leandra Scordamaglia Big Smile