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

Announcements
Posting on Qlik Community is temporarily paused for some users. Thank you for patience and we'll update you soon!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

SALES AND PRE SALES

Hi...!!!

Please suggest how to derive 

PRE SALES

DIFF

PER(%)

as per the below mentioned details and my data only contains 2 fields i.e YEAR and SALE


YEARSALEPRE SALESDIFFPER(%)
20012000
20022500200050025
200343002500180072
200420004300-2300-53.48837209
200510002000-1000-50
2006500010004000400
200746785000-322-6.44
200886234678394584.33091065
200972908623-1333-15.45865708
201047267290-2564-35.17146776
201185644726383881.21032586


PRE SALESPERVIOUS YEAR SALES
DIFFDIFFERENCE OF CURRENT SALES AND PRE SALES



Thanking You

Vinayagam

Labels (1)
1 Solution

Accepted Solutions
maxgro
MVP
MVP

RESULT

2014-03-20 09_56_12-Il Kindle di massimo per PC - Programming in HTML5 with JavaScript and CSS3_ Tra.png


SCRIPT

Source:

load * inline [

YEAR, SALE

2001, 2000

2002, 2500

2003, 4300

2004, 2000

2005, 1000

2006, 5000

2007, 4678

2008 ,8623

2009, 7290

2010, 4726

2011, 8564

];

Table:

NoConcatenate

load

YEAR, SALE,

peek(SALE) as PREVSALE,

SALE - peek(SALE) as DIFF,

(SALE - peek(SALE)) / peek(SALE) as DIFF%

Resident

Source

order by YEAR;

DROP Table Source;

View solution in original post

11 Replies
its_anandrjs
Champion III
Champion III

Hi,

Use Peek() and previous function for this

Thanks & Regards

maxgro
MVP
MVP

RESULT

2014-03-20 09_56_12-Il Kindle di massimo per PC - Programming in HTML5 with JavaScript and CSS3_ Tra.png


SCRIPT

Source:

load * inline [

YEAR, SALE

2001, 2000

2002, 2500

2003, 4300

2004, 2000

2005, 1000

2006, 5000

2007, 4678

2008 ,8623

2009, 7290

2010, 4726

2011, 8564

];

Table:

NoConcatenate

load

YEAR, SALE,

peek(SALE) as PREVSALE,

SALE - peek(SALE) as DIFF,

(SALE - peek(SALE)) / peek(SALE) as DIFF%

Resident

Source

order by YEAR;

DROP Table Source;

Not applicable
Author

Hi,

Dimension: Year

Expression for Sales: sum(SALE)

Expression for Presales: above(sum(SALE),1)

senpradip007
Specialist III
Specialist III

Hi.

You can use above(Sum(SALE),1) function to get this result.

alexandros17
Partner - Champion III
Partner - Champion III

Here is an example

its_anandrjs
Champion III
Champion III

Hi,

Load your table some thing like below

Temp:

LOAD * Inline

[

YEAR, SALE

2001, 2000

2002, 2500

2003, 4300

2004, 2000

2005, 1000

2006, 5000

2007, 4678

2008, 8623

2009, 7290

2010, 4726

2011, 8564

];

Temp2:

load

YEAR,

SALE,

Previous(SALE) as Presale

Resident Temp;

DROP Table Temp;

Data:

load

YEAR,

SALE,

Presale,

SALE-Presale as diff

Resident Temp2;

DROP Table Temp2;

Hope this helps

Thanks

its_anandrjs
Champion III
Champion III

Hi,

Here is updated one lets see

Temp:

LOAD * Inline

[

YEAR, SALE

2001, 2000

2002, 2500

2003, 4300

2004, 2000

2005, 1000

2006, 5000

2007, 4678

2008, 8623

2009, 7290

2010, 4726

2011, 8564

];

Temp2:

load 

YEAR,

SALE,

Previous(SALE) as Presale

Resident Temp;

DROP Table Temp;

Data:

load

YEAR,

SALE,

Presale,

SALE-Presale as Diff,

(SALE-Presale) / Presale as Diff%

Resident Temp2;

DROP Table Temp2;

Hope this helps

Thanks & Regards

Not applicable
Author

Thanks ton...!!!!

Not applicable
Author

Thanks ton...!!!!