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: 
praveensprabhu
Contributor II
Contributor II

Need help to pick latest 2 field values

Hello Qlik experts,

I am working on a application, where in I am required to pick 2 latest supplier values from a available list along with only one latest sqe_name.

I am showcasing below sample data using which if some1 could help me achieve this.

praveensprabhu_1-1613649444119.png

in the above screenshot, data is sorted in desc order and the top 2 suppliers and top1 sqe needs to displayed as below-

praveensprabhu_2-1613649738327.png

Another example - 

data table sorted by date in desc order

praveensprabhu_3-1613650248321.png

 final output should look like this - 

praveensprabhu_4-1613650361215.png

 

Could some1 please help me to achieve this? 

I am attaching the sample data for reference. 

Labels (2)
1 Solution

Accepted Solutions
Saravanan_Desingh

Try this,

supplier1: FirstSortedValue(supplier_name,-date)

supplier2: FirstSortedValue(supplier_name,-date,2)

sqe: If(IsNull(FirstSortedValue(sqe_name,-date)),FirstSortedValue(sqe_name,-date,2),FirstSortedValue(sqe_name,-date))

View solution in original post

3 Replies
madhu_r
Partner - Contributor III
Partner - Contributor III

Hi Praveen,

Use the expression to get top 1 supplier:- Aggr(Only({<date={"$(=Max(date))"}>}supplier_name),supplier_name)

top 2 supplier:- Aggr(Only({<date={"$(=Date(Max(date,2)))"}>}supplier_name),supplier_name)

Please find the attached working file.

 

Saravanan_Desingh

Try this,

supplier1: FirstSortedValue(supplier_name,-date)

supplier2: FirstSortedValue(supplier_name,-date,2)

sqe: If(IsNull(FirstSortedValue(sqe_name,-date)),FirstSortedValue(sqe_name,-date,2),FirstSortedValue(sqe_name,-date))

Saravanan_Desingh

Output:

commQV05.PNG