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

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

Select Actual Month

Hello all,

I want to select the actual month in my QlikView Document when accessing this and the previous and following months from a half year.

So, for example: There are two quarters. One from April to September. The other one from October to March.

Let's say the actual month is May. Now, QlikView should select April and May to September.
On June it should select May and June to September.
On July it should select June and July to September.
And so on ...

As example I attached an Excel File "Forum", which should give a short overview behind the "system".

Thanks!

[View:http://community.qlik.com/cfs-file.ashx/__key/CommunityServer.Discussions.Components.Files/11/2248.Forum.xlsx:550:0]

2 Replies
Not applicable
Author

Hi HofbauerAn

1. In your script define 2 variables with the current and previous month.

2. Write a macro to make the selection of these two months in "Tools" -> "Edit Module":

Sub InitialSettings

SET Month1 = ActiveDocument.Variables("YourVariable1")

SET Month2 = ActiveDocument.Variables("YourVariable2")

ActiveDocument.Fields("TheMonthNameInYourQVW1"). Select Month1.GetContent. String

ActiveDocument.Fields("TheMonthNameInYourQVW1"). Select Month2.GetContent. String

End Sub

3. In "Settings -> "Document Properties" -> "Triggers", you can have a trigger executed each time the report is opened using the "Document Event Trigger" called "OnOpen". Call the "InitialSettings" trigger here.

Best regards

Frederik

Not applicable
Author

Hi, thanks for your answer.

I tried your suggestion, but QlikView is only selecting the actual month - not all the mont I need.
I created two variables:

previousmonth =month(today()-1)
and
currentmonth =month(today())

My macro looks like this:
sub InitialSettings

SET Month1=ActiveDocument.Variables("previousmonth")
SET Month2=ActiveDocument.Variables("currentmonth")

ActiveDocument.Fields("Month").Select Month1.GetContent.String
ActiveDocument.Fields("Month").Select Month2.GetContent.String

End Sub

Thanks for help!