# QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
cancel
Showing results for
Did you mean:
Not applicable

## aggr/rank to calculate newest 4 entries

Hello,

I want to calculate an average for the value Ist_Pk for each [Masch.-Nr.] but it does not work.

I tried to combine Rank and Aggr function to first rank the the field "Woche" because this contains the information about the date. this means the highest 4 entries for each [Masch.-Nr.] should be Aggr. to an avg of Ist_Pk.

i tried

IF(AGGR(RANK(Woche), [Masch.-Nr.]) <= 4,avg(Ist_Pk))

Does someone have an idea how to do this?

thanks, armin

1 Solution

Accepted Solutions
MVP

Try

=Avg( Aggr( IF(RANK(Woche)<=4, Ist_Pk), [Masch.-Nr.],Woche))

2 Replies
MVP

Try

=Avg( Aggr( IF(RANK(Woche)<=4, Ist_Pk), [Masch.-Nr.],Woche))

Luminary Alumni

Hi,

Try like this

Avg(AGGR(IF( RANK(Woche)<= 4, Sum(Ist_Pk)) , [Masch.-Nr.], Woche) )

OR

Avg(AGGR(IF( RANK(Woche)<= 4, Only(Ist_Pk)) , [Masch.-Nr.], Woche) )

OR

Avg(AGGR(IF( RANK(Woche)<= 4, Avg(Ist_Pk)) , [Masch.-Nr.], Woche) )

Regards.

Jagan.