Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to calculate the Growth

Dear All,

I here by attached my sample data, which i want to calculate the growth. can any one help me in this regard.

Rgds,

Priyantha.

19 Replies
Not applicable
Author

Hi Krishna,

Thanks for early reply,

As this is sample data i have mentioned only 03 products. in my actual data base i have more more than 100 product codes. Therefore it's impossible to use your suggestion  .

Rgds.

Priyantha.

Not applicable
Author

Dear Gupta,

My table like this,

   

PRD_CODEBCODMONTHYEARPTPRGROWTH
1AB100APR2012178740
1BB100APR2012214184
1CB100APR2012205433

  

1ABB00APR201348813
1BBB00APR201376630
1CBB00APR2013-36508

  

1ABB00APR2014128540
1BBB00APR20144402
1CBB00APR201451992

I want to calculate the Growth of 2013 against the results of 2012.  and 2014 growth against the year 2013.

What is the formula i should applied.

Simple example for 2014 1A product, = (128540-48813)/48813

Please help,

Rgds,

Priyantha.

Not applicable
Author

Dear Snehal,

Your Expression status is OK, But something the is some thing wrong and expression result shows zero.

See the following table.

BCOD MO_NM CLA_CODE NEWRENADDREFUNDTOTALNO.POLBUDGETACH%LAST_YEARGRO%
BA00MOTORM359316793210013863725963350022%00.00%
M49694955605001525542445250337%00.00%
MC194324436037252025617443903822835122384625099%00.00%
Total 2099509 3738651 20256 1744390 4114026 405 4525000 91% 0 0.00%
NON_MOTOREN157200779000492001859002150220124%00.00%
FR1281034754732790013889049258611450660109%00.00%
HH6220138360024200120380685840140%00.00%
MR000000214600%0
MS3415832421000926604910231553650092%00.00%
PP95471979000293374723606012%00.00%
SS0133320011565121755112876095%00.00%
TC3884135188753451797602163132349358044%00.00%
TT000000429200%0
Total 681494 1438830 33245 496275 1657294 105 2146000 77% 0 0.00%
Total 2781003 5177481 53501 2240665 5771320 510 6671000 87% 0 0.00%
jagan
Luminary Alumni
Luminary Alumni

Hi,

Try like this in script

Temp:

LOAD * INLINE [

    PRD_CODE, BCOD, MONTH, YEAR, PTPR

    1A, B100, FEB, 2012, 151253

    1B, B100, FEB, 2012, 142792

    1C, B100, FEB, 2012, 328884

    1A, B100, JAN, 2012, 130269

    1B, B100, JAN, 2012, 314794

    1C, B100, JAN, 2012, 307519

    1A, B100, MAR, 2012, 204227

    1B, B100, MAR, 2012, 259359

    1C, B100, MAR, 2012, 369557

    1A, BB00, FEB, 2013, 404408

    1B, BB00, FEB, 2013, 108903

    1C, BB00, FEB, 2013, 79301

    1A, BB00, JAN, 2013, -17120

    1B, BB00, JAN, 2013, 214956

    1C, BB00, JAN, 2013, 270775

    1A, BB00, MAR, 2013, -141303

    1B, BB00, MAR, 2013, 144465

    1C, BB00, MAR, 2013, 261256

    1A, BB00, FEB, 2014, 227194

    1B, BB00, FEB, 2014, 139685

    1C, BB00, FEB, 2014, 156541

    1A, BB00, JAN, 2014, 112225

    1B, BB00, JAN, 2014, -24225

    1C, BB00, JAN, 2014, 469485

    1A, BB00, MAR, 2014, 259808

    1B, BB00, MAR, 2014, 276639

    1C, BB00, MAR, 2014, 4107

];

LOAD

*,

If(PRD_CODE = Peek(PRD_CODE) AND MONTH = Peek(MONTH),  Peek(PTPR), PTPR) AS PreviousValue

RESIDENT Temp

ORDER BY PRD_CODE, MONTH, YEAR;

DROP TABLE Temp;

Regards,

Jagan.

Not applicable
Author

Dear Jagan Mohan,

Thanks lot for the early reply.

As I have uploaded sample data only i have mentioned 03 'PRD_CODE's.  In my database i have more than 100 'PRD_CODE's. So It's impossible to load all the 'PRD_CODE's in the script level.

My attempt is to find an expression to calculate the growth like this

Growth = [Current year same month PTPR - Last year same month PTPR]/Last year same month PTPR

So how can i do this calculation through an Expression.

Rgds,

Priyantha.

jagan
Luminary Alumni
Luminary Alumni

Hi,

You can replace Inline script with your data, it works even if you have 1000s of products, the logic is same, I just given Inline for test purpose.

Temp:

LOAD *

FROM FileName;

Data:

LOAD

*,

If(PRD_CODE = Peek(PRD_CODE) AND MONTH = Peek(MONTH),  Peek(PTPR), PTPR) AS PreviousValue

RESIDENT Temp

ORDER BY PRD_CODE, MONTH, YEAR;

DROP TABLE Temp;

Now you can use

=(PTPR - PreviousValue)/PreviousValue

Hope this helps you.

Regards,

Jagan.

SreeniJD
Specialist
Specialist

Hi Priyantha,

Please try to have three pre aggregated facts like Growth_cur, Growth_prev1, Growth_prev2 and calculate accordingly. this will simplify your calculation and will be robust for handling huge data.

Let me know if you need a script.

Thanks,

Sreeni

Not applicable
Author

Dear Jagan,

I have tried the way you introduced and observed that "previous value" in your scrip represents the same value as the Current PTPR. So something wrong in the script .

Please  Help.

Rgds,

Priyantha. 

Not applicable
Author

Dear Sreeni,

Thaks for the early reply,

Script Please.

Rgds,

Priyantha.

Not applicable
Author

Hi Priyantha,

Hope this will help u.