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

Announcements
Independent validation for trusted, AI-ready data integration. See why IDC named Qlik a Leader: Read the Excerpt!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Macro Problem: Selecting Previous Month

Hi,

I have a problem in where i'm showing a Balanced Score Card on my dashboard. My employer asked me to select the previous month by default so that the tables show some values when the user views the dashboard. The only way conceivable of doing this, as I have found so far is to create a Macro function that runs on a trigger when OpenDocument occurs. I was able to get the current month and year by doing this:

     sub DefaultLAFP2

     v_monthyear = UCASE(Monthname(Month(now()),TRUE)) & " " & right(Year(now()),2)

     ActiveDocument.Fields("MonthYear").Select v_monthyear

     end sub

The MonthYear field has values such as: JAN 13, FEB 13, MAR 13, etc...

When I tried putting the -1 after the Month I was unable to get the desired result. I believe this is because QlikView doesn't let you subtract a month since in January it would crash. How can I achieve what I need? Help please.

1 Solution

Accepted Solutions
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

You don't have to use a macro. You can add a Select in Field action to the trigger instead. Choose MonthYear as field and try as search string =date(addmonths(today(),-1),'MMM YY').


talk is cheap, supply exceeds demand

View solution in original post

2 Replies
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

You don't have to use a macro. You can add a Select in Field action to the trigger instead. Choose MonthYear as field and try as search string =date(addmonths(today(),-1),'MMM YY').


talk is cheap, supply exceeds demand
Not applicable
Author

That was the exact solution that I wanted. Thank you very much for your response.