Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
kinjal1645
Creator
Creator

FirstSortedValue() with time period

Hi,

 

Can someone help with the below?

I have the following data:

ID1ID2Date_receivedPeriodRank_type1Rank_type2
P00217616/18/201H203 
P00217616/18/201H20 2
P002176111/24/202H205 
P9800345128/24/201H208 
P9800 8/24/201H20 4
P9800 6/2/212H207 

 

And below is the expected output:

ID1ID2Rank_type1 CurrentRank_type1 PreviousRank_type2 CurrentRank_type2 Previous
P0021761532 
P9800345128   
P9800 7 4 

 

I used this expression: FirstSortedValue(DISTINCT Rank_type1), -Date_received

But I am only getting the current rank with this expression and also rank_type2 comes blank

ID1ID2Rank_type1 CurrentRank_type1 PreviousRank_type2 CurrentRank_type2 Previous
P00217615   
P9800345128   
P9800 7   

 

@sunny_talwar @swuehl @Gysbert_Wassenaar @Anil_Babu_Samineni @tresesco 

 

Kindly help

Thank you

4 Replies
tresesco
MVP
MVP

What exact expression are you using for 'Rank_type1 Previous'? Could you share your sample app?

kinjal1645
Creator
Creator
Author

Current 

FirstSortedValue(DISTINCT Rank_type1, -Date_received)

Previous 

FirstSortedValue(DISTINCT Rank_type1, -Date_received, 2)

tresesco
MVP
MVP

With those expressions I am getting the expected output.

tresesco_0-1621920430168.png

 

kinjal1645
Creator
Creator
Author

Hi Tresesco,

I am not getting correct output.

I have created a sample file. 

Below is the expected output:

expected output.png

Current output:

current output.png

Would you be able to help?