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

Announcements
April 13–15 - Dare to Unleash a New Professional You at Qlik Connect 2026: Register Now!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Macro to select latest 12 months

Hello everyone,

I know macros are bad and i should not use them..

But i have to know this.

Can anyone help me with the syntax of macro to select latest 12 months from a date dimension.

ActiveDocument.Fields("ShipDate","State-A").Select ActiveDocument.Evaluate("date(date#(addmonths(max(ShipDate),-12),'DD-MM-YYYY'),'DD-MM-YYYY')")

The above helps me select max-12 month.

But i want to select all last 12 months?

Thanks

khushboo

1 Solution

Accepted Solutions
marcus_sommer

Try this:

ActiveDocument.Fields("ShipDate","State-A").Select ">=" & ActiveDocument.Evaluate("date(date#(addmonths(max(ShipDate),-12),'DD-MM-YYYY'),'DD-MM-YYYY')")

- Marcus

View solution in original post

2 Replies
marcus_sommer

Try this:

ActiveDocument.Fields("ShipDate","State-A").Select ">=" & ActiveDocument.Evaluate("date(date#(addmonths(max(ShipDate),-12),'DD-MM-YYYY'),'DD-MM-YYYY')")

- Marcus

Not applicable
Author

Thanks Marcus 🙂