Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
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
Not applicable
Author

please can you share your qvw?

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

Regards,

Luis

Gysbert_Wassenaar

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
Not applicable
Author

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)'

Not applicable
Author

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

james_wynn
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'))