Qlik Community

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
IMPORTANT security patches for GeoAnalytics Server available to download: READ DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

sum of current year and previous year sales in script

Hi Team,

I want a field year and sales. I want to create a new field accumulatesales which should be sum of current year sales + previous year sales.

How to create this new field in the script?

Please provide your suggestions.

Thanks,

SV

3 Replies
hemhund2016
Creator
Creator

Hi,

Use this.

Table_Sales:

LOAD year,

           sum(sales) as sales,

           from ****YOUR SOURCE**;

left join(Table_Sales)

LOAD year,

           sum(sales) +Previous(sales) as New_Sales

           Resident

           Temp_Sales

          order by year asc;

maxgro
MVP
MVP

it depends on your data

this could be a solution

1.png


z:

load * inline [

Year, Sales

2010, 100

2011, 110

2012, 120

2013, 130

2014, 140

2015, 100

];

zz:

load Year, Sales + Previous(Sales) as TwoYearSales Resident z order by Year;



Not applicable
Author

test1:

load * inline [

year, Sales

];

test2:

load year,

if(IsNull(Sales + Previous(Sales)),Sales,(Sales + Previous(Sales))) as PreviousSales

Resident z Order by Year;