Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Average of last 2 values per entity

Hello All,

I have a problem if someone could help me please.

Let's say I have some entities A, B & C and each of these entities have some scores at different dates

Entity                Score               Date

A                         80                    01/01/2015

A                         85                    02/03/2015

A                         90                    05/06/2015

B                         90                    01/02/2015

B                         95                    06/01/2015

B                         100                  01/01/2016

C                         80                   11/02/2015

C                          85                   01/01/2016

Now I want the average for only last two scores for each entity so for entity A i want average of 85 and 90, for B i want average of 95 and 100 and for C average of 80 and 85.

Is there a way to accomplish this?

thanks,

1 Solution

Accepted Solutions
sunny_talwar

May be try this:


Dimension: Entity


Expression:

RangeAvg(FirstSortedValue(Score, -Date), FirstSortedValue(Score, -Date, 2))

View solution in original post

2 Replies
sunny_talwar

May be try this:


Dimension: Entity


Expression:

RangeAvg(FirstSortedValue(Score, -Date), FirstSortedValue(Score, -Date, 2))

Not applicable
Author

Excellent! Thanks Sunny!