Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
amars
Specialist
Specialist

Macro to select Previous Month from Current.

Hi all,

I wish to select previous month as soon I open a Qlikview Dashboard. I have tried various expression e.g.

I have a field called [Start Date of Month] to represent each month , so I tried ActiveDocument.GetField("Start Date of Month").Select ActiveDocument.Evaluate("=AddMonths(Max([Start Date of Month]),-1)") But Max([Start Date of Month]) work's with the Current month but when I use AddMonth with -1 for previous month the Time value I hope is truncated & it doesn't select Desired result.

I have tried various ways but because the Time Factor along with date get's truncated it is not working. If someone could give any suggestion. Thanks in advance

With Regards

Amar

3 Replies
Not applicable

Hi,

You can create an variable with expression as below to get the previous month;

X=Month(AddMonths(today(),-1))

And select the month using macro

Get the variable as string

ActiveDocuemnt.Fields("[Start Date of Month]"). Select X

I hope the above will help you.

Regards

Rajesh

amars
Specialist
Specialist
Author

Hi Rajesh,

It won't work since in my database [Start Date of Month] is an DateTime Field & in Qlikview Month(AddMonths(today(),-1)) will give me some value that just has a Date Value & not the time along with it so the selection don't work in this case. If some one has faced such a problem please reply.

with regards

Amar

Not applicable

HI,

Create month from '[Start Date of Month]' filed in qlikview and use that field for selection.

ActiveDocument.Fields("[CREATED MONTH]").Select X

- Sridhar