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

Announcements
Share your agentic AI experience, learn from others, and earn a new badge: Put Agentic AI to Work
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

Labels (1)
1 Solution

Accepted Solutions
marcus_sommer
MVP
MVP

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
MVP
MVP

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 🙂