# QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
Contributor III

## Previous 6 months sum in Script level ?

Hi All,

How can i calculate previous 6 months Sales here in below script.

Note: In UI level i can achieve this, finding difficulty to calculate in script level .

Thank You,

Cheers,

Ganesh

Tags (4)
7 Replies
Honored Contributor

## Re: Previous 6 months sum in Script level ?

use set analysis

sum({<yourdatefield={'>={\$(=addmonths(max(yourdatefield),-6))}<=yourdatefield{\$(=max(yourdatefield))}'}>}sales)

maybe you need to adjust expression

Contributor III

## Re: Previous 6 months sum in Script level ?

Hi Rudolf,

I suppose we can not use set analysis in script. I want to calculate in Script as like Sum(Sales) which i did in script.

Cheers,

Ganesh

Honored Contributor II

## Re: Previous 6 months sum in Script level ?

something like the attached?

Honored Contributor II

## Re: Previous 6 months sum in Script level ?

note the set statement :

SET DateFormat='DD/MM/YYYY';

and use a calendar :

Understanding the Master Calendar (video)

Contributor III

## Re: Previous 6 months sum in Script level ?

Hi ioannis,

if i want Current Month vs next 3 rolling month than what i need to do?

thanks

Honored Contributor II

## Re: Previous 6 months sum in Script level ?

AsOfMonth:

load

Month as Month_AsOf,

Month + 1 + IterNo() as Month

Resident tmp_SO

while IterNo() <= 3;

plus in IterNo instead of minus

and 3 instead of 6 in the while clause

see Calculating rolling n-period totals, averages or other aggregations for more details / suggestions

Contributor

## Re: Previous 6 months sum in Script level ?

sum({<datefield={">=\$(=addmonths(max(datefield),-6))<=datefield\$(=max(datefield))"}>}sales)

use if() in script level