Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Just an Average ! ?

Hi,

I have a Pivot table with a set of Complex calculation. I will try to make my question as simple as possible.

The table looks something like;

Year2013201420152016
Duration
51211
101.5122

The Table is a Pivot Table,  hence Duration and Year are dimensions.

The requirement is to get the Average of [curr Year, cur Year+1, cur Year+2 ]  for every year / duration

Thus, the table should look like;

Year2013201420152016
Duration
51.331.330.660.33
101.51.661.330.66

Appreciate any help !

Thanks

1 Solution

Accepted Solutions
sunny_talwar

Script:

Table:

LOAD * Inline [

Duration, Year, Data

5, 2013, 1

5, 2014, 2

5, 2015, 1

5, 2016, 1

10, 2013, 1.5

10, 2014, 1

10, 2015, 2

10, 2016, 2

];

Expression: =(Alt(Data, 0) + Alt(After(Data), 0) + Alt(After(Data, 2, 0), 0))/3


Output:

Capture.PNG


HTH

Best,

Sunny

View solution in original post

3 Replies
swuehl
MVP
MVP

Try something like

=Rangesum( YourExpression, after(YourExpression,1) after(YourExpression,2) ) / 3

alexandros17
Partner - Champion III
Partner - Champion III

Try with this expression:

RangeAvg(Value, After(Value), After(After(Value)))

sunny_talwar

Script:

Table:

LOAD * Inline [

Duration, Year, Data

5, 2013, 1

5, 2014, 2

5, 2015, 1

5, 2016, 1

10, 2013, 1.5

10, 2014, 1

10, 2015, 2

10, 2016, 2

];

Expression: =(Alt(Data, 0) + Alt(After(Data), 0) + Alt(After(Data, 2, 0), 0))/3


Output:

Capture.PNG


HTH

Best,

Sunny