Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
kunkumnaveen
Specialist
Specialist

previous score

Hello All, I am looking for suggestion from you guys,let us suppose if my given  data is like below

location      date            score

mumbai      06/13/2015      40

mumbai      09/20/2015      50

mumbai      12/05.2015      60

pune            05/14/2015      100

pune            07/22/2015        110

pune            11/28/2015        120  

Now...the whats the requirement is :

location      currentscore      previousscore

mumbai          60                      50

pune                120                      110

i had achieved the current score requirement by using this:    firstsortvalue(score,-date) which gives me max date score which is current score

so will u guys please let me known how to achieve previous score

thanks

naveen

6 Replies
MK_QSL
MVP
MVP

Use 2nd expression as below to get the previous score..

FirstSortedValue(score,-date,2)

jagan
Luminary Alumni
Luminary Alumni

HI,

You can specify the 3rd parameter for this

firstsortvalue(score,-date, 2)  - This gives the previous score.


Regards,

Jagan.

MK_QSL
MVP
MVP

You selected answer as helpful so I am assuming that you haven't got the right answer. Please let us know the same so that we can help you further.

kunkumnaveen
Specialist
Specialist
Author

Hello Manish, i do got the answer what i am looking for , to close the thread i selected helpful..so if it is not the right way to close the thread please let me known how to close the thread

thanks

naveen

Mark_Little
Luminary
Luminary

Hi,

You could always get the previous in the script,

Something like,

Load

     *

     IF(Rowno() =1 or Location <> PEEK(Location,-1),  

          0,

          PEEK(Score,-1) )              AS PreviousScore

Resident 'Your table'

Order by Location, date;

Mark

MK_QSL
MVP
MVP

Correct Answer is the one which can close the thread... Helpful means the thread is still open and you are looking for the correct answer.