Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
Qlik1_User1
Specialist
Specialist

Top 2 lastest date data

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 latest date data for Product A

 

ProductOrder dateSalesCountry
A12/12/201710India
A10/10/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

A30US
A10India

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

Below is the expression I am using but its give 0 as a result

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

1 Solution

Accepted Solutions
Qlik1_User1
Specialist
Specialist
Author

got the solution

 

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

View solution in original post

3 Replies
bharadwaj
Partner - Contributor II
Partner - Contributor II

Hi,

Try the following expression:

if(Product ='A',Sum(If(Aggr(NODISTINCT Max(Order date), Product) = Order date, Sales)) +
Sum(If(Aggr(NODISTINCT Max(Order date,2), Product) = Order date , Sales)),0)

Hope it helps

Regards

Qlik1_User1
Specialist
Specialist
Author

got the solution

 

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