# QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

New Contributor II

## Pivot table with calculation year to year

Hi,

I'm trying to create pivot table with following structure, but can't correctly calculate Evolution.

In my model I have weight and height and based on it I calculate index as Heigth/Weigth.

Evolution should be counted by comparing current year with previous (2017 vs 2016, 2016 vs 2015, 2015 vs 2014)

Can someone help with set expression.

 Year 2014 2015 2016 2017 Weigth 81 87 91 98 Height 179 181 184 190 Index 0,45 0,48 0,49 0,52 Evolution 6,22 2,89 4,29
1 Solution

Accepted Solutions
MVP

## Re: Pivot table with calculation year to year

Try this:

=((Weight/Height)/Before(Weight/Height) - 1) * 100

8 Replies
MVP

## Re: Pivot table with calculation year to year

Is Weight and Height part of a single dimension or are they dimensions itself? Would you be able to share raw data behind this to help you better?

New Contributor II

## Re: Pivot table with calculation year to year

Weight and Height are dimensions itself

MVP

## Re: Pivot table with calculation year to year

Would you be able to share sample data or a sample qvw file?

New Contributor II

## Re: Pivot table with calculation year to year

Hi Sunny,

Please find sample qvw in attachment

Honored Contributor

## Re: Pivot table with calculation year to year

What exactly is compared when calculating the Evolution ? You can give an example of the calculation of Evolution for at least one year?

MVP

## Re: Pivot table with calculation year to year

Try this:

=((Weight/Height)/Before(Weight/Height) - 1) * 100

New Contributor II

## Re: Pivot table with calculation year to year

Thank you. I didn't know about before function

MVP

## Re: Pivot table with calculation year to year

You can check out after and before here:

Missing Manual - Before() and After()