Qlik Community

Ask a Question

New to Qlik Sense

If you’re new to Qlik Sense, start with this Discussion Board and get up-to-speed quickly.

Announcements
Our next Qlik Insider session will cover new key capabilities. Join us August 11th REGISTER TODAY
cancel
Showing results for 
Search instead for 
Did you mean: 
Qlik1_User1
Creator III
Creator III

Fetching latest records top 2

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
tresesco
MVP
MVP

Put your product condition within the rank(), like:

 

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

View solution in original post

6 Replies
settu_periasamy

Hi,

This expression is working fine for me.

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

2020-02-16_12h12_10.png

Qlik1_User1
Creator III
Creator III
Author

It seems you have made selections in Product column for value A.

When I am using this same expression I am getting 0 records , I am doing it in Qlik sense

tresesco
MVP
MVP

Put your product condition within the rank(), like:

 

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

View solution in original post

Qlik1_User1
Creator III
Creator III
Author

Thanks a lot it worked 🙂

settu_periasamy

Yes. Forgot to deselect.

Qlik1_User1
Creator III
Creator III
Author

Thanks for the help 🙂