Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
Modernize Your QlikView Deployment webinar, Nov. 3rd. REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Not applicable

Macro for selecting data range is not working

Hi All,

I have the following issue:

Im trying to select only the last 30 days in a Macro Sub.

I 2 Have qlikview Variables:

1. "vMaxDate" gets the max date we have in the system

2. "vMinDay30" gets the max date -30.

So I would like to select everything in between.

my Sub is:

sub select30days

ActiveDocument.ClearAll false

First= ActiveDocument.Variables("vMinDay30").GetContent.String

Last= ActiveDocument.Variables("vMaxDate").GetContent.String

mySelect= ">" & First & "<" & Last

ActiveDocument.Fields("DateOnly").Select mySelect

end sub

but even after I test it, it does not select a thing.

Any advice?

thank you

Ella

5 Replies
Highlighted
Not applicable

please can you share your qvw?

I replicated with an own example and the macro works fine.

Regards,

Luis

Highlighted
MVP & Luminary
MVP & Luminary

Works for me. Check that the date format is correct. You can add some msgbox statements to check the values of the variables.

Anyway.... why use a macro at all? The Clear All and Select in Field actions work just as well and will also work work correctly in the ajax client.


talk is cheap, supply exceeds demand
Highlighted
Not applicable

Hi, you don't need a Macro for this requirement. Just create a Button or text object and create Action with "Select in Field" option

Field: Date Expression:  ='>=$(=Max(Date)-30)'

Highlighted
Not applicable

dathu.gv ... I created a button and pasted in exactly what you recommended and it does not work:

Select in Field

Field: Date (yes my system has a "Date" field)

Search String: ='>=$(=Max(Date)-30)'

Macro works fine

Highlighted
Contributor
Contributor

Rob,

dathu is correct; a button and Select in Field will work.

Always format your dates, in qlikview.

Field name: [Rpt Date]

value field: = max(date([Rpt Date],'MM/DD/YYYY'))