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

Announcements
ALERT: QlikView server communication interruptions following Microsoft Windows Domain Controller security updates
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Last 12 Months

Hi All,

Need to show last 12 months of data based on existing date filed. How can i achive this ?

Thanks

Labels (1)
1 Solution

Accepted Solutions
jagan
Partner - Champion III
Partner - Champion III

Hi,

Try this expression

='QTY= ' & sum({<Trans_Date={'>=$(=MonthStart(Max(Trans_Date), -11))<=$(=Max(Trans_Date))'}>}QTY)

Create variable with vMaxDate = Max(Trans_Date) and then use below expression

='QTY= ' & sum({<Trans_Date={'>=$(=MonthStart(vMaxDate, -11))<=$(=vMaxDate)'}>}QTY)

Hope this helps you.

Regards,

Jagan.

View solution in original post

3 Replies
jagan
Partner - Champion III
Partner - Champion III

Hi,

Try this expression

='QTY= ' & sum({<Trans_Date={'>=$(=MonthStart(Max(Trans_Date), -11))<=$(=Max(Trans_Date))'}>}QTY)

Create variable with vMaxDate = Max(Trans_Date) and then use below expression

='QTY= ' & sum({<Trans_Date={'>=$(=MonthStart(vMaxDate, -11))<=$(=vMaxDate)'}>}QTY)

Hope this helps you.

Regards,

Jagan.

Not applicable
Author

Hi Jagan,

Is it possible to load last 12 months of data while loading the data in the script ?

jagan
Partner - Champion III
Partner - Champion III

Hi,

Use script below to reduce last 12 months in script level

DataTemp:

Data:

LOAD Max(Trans_Date) AS MaxDate

FROM

Last12Months.xlsx

(ooxml, embedded labels, table is Sheet1);

let vMaxDate = Peek('MaxDate');

Data:

LOAD Trans_Date,

     QTY

FROM

Last12Months.xlsx

(ooxml, embedded labels, table is Sheet1)

where Trans_Date >= AddMonths($(vMaxDate), -12) AND Trans_Date <= $(vMaxDate);

Regards,

Jagan.