Qlik Community

QlikView Layout & Visualizations

Discussion Board for collaboration on QlikView Layout & Visualizations.

Not applicable

Calculate price variation

Hi I need to do something very simple, I have to calculate a price variation during the year..

I have:

     price1

     price2

     price3

     price4

     price5

     price6

     price7

And I want: (price2-price1)/price1

     ..(price3-price2)/price2....

     (price4-price3)/price3 and so on....

How can I do that in a table? I tried to to the ratio but It doesn't show any value!

6 Replies

Re: Calculate price variation

Are those different fields in a table or values in one field? If they are values in one field you can try using the above() function. For example with a table that contains a Date field and a Price field you could create a straight table with Date as dimension and use Price/above(Price) - 1 as expression.


talk is cheap, supply exceeds demand
Not applicable

Re: Calculate price variation

Are different field in a table

Re: Calculate price variation

Then you need a different expression for each variation calculation:

Expression1: Price2/Price1 -1

Expression2: Price3/Price2 -1

...etc


talk is cheap, supply exceeds demand
nagaiank
Valued Contributor III

Re: Calculate price variation

Does the following script give a clue to solve your problem?

Data:

LOAD RowNo() as ID, * Inline [

Price

10

11

12

13

14

15

13

11

];

Final:

NoConcatenate

LOAD ID,Price,

If(IsNull(Peek('Price')),Null(),(Price-Peek('Price'))/Peek('Price')) as Ratio

Resident Data Order By ID;

DROP Table Data;

Not applicable

Re: Calculate price variation

I'm trying to do that but It doesn't shows any value just an hyphen!

Re: Calculate price variation

Can you post an example document that demonstrates the problem?


talk is cheap, supply exceeds demand
Community Browser