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

Announcements
Streamlining user types in Qlik Cloud capacity-based subscriptions: Read the Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Qlik1_User1
Specialist
Specialist

Top 2 records based on dates

Hi All,

below is sample data, need to get the latest 2 records as per date in chart..i don't want to make use of back end scripting for this as i need all the records , only in this chart want to show top 2 records

Need to fetch Top 2  data for Product A based on order date

ProductOrder dateSalesCountry
A12/12/201710India
A12/12/201720Japan
A1/2/201930US
A10/17/201740Canada
B10/27/201950India
B1/3/202060Japan
B4/4/201870US
B5/12/201880Canada
B7/10/202190Japan
B5/11/2020100US

 

Expected Output

A20Japan
A30US

In chart only Product,Country and SUM(sales) needs to be displayed

Below is the expression I am using and its give below result

sum({<[Order date]={"=rank(if(Product='A', [Order date]))<=2"}>}Sales)

Output coming - 

A10India
A20Japan
A30US

 

Expected Output

A20Japan
A30US

Please suggest,its very urgent.

4 Replies
jcdatasax
Contributor III
Contributor III

Typing on my phone,  but this can be achieved with the FirstsortedValue...  a quick google can get you there. 

Qlik1_User1
Specialist
Specialist
Author

Tried but didn't worked..

dwforest
Specialist II
Specialist II

Why would you not expect India as it also has a 12/12 date?

Qlik1_User1
Specialist
Specialist
Author

Because than 3 reords will starts coming and we need to shown only top 2..