Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
Product | Order date | Sales | Country |
A | 12/12/2017 | 10 | India |
A | 10/10/2017 | 20 | Japan |
A | 1/2/2019 | 30 | US |
A | 10/17/2017 | 40 | Canada |
B | 10/27/2019 | 50 | India |
B | 1/3/2020 | 60 | Japan |
B | 4/4/2018 | 70 | US |
B | 5/12/2018 | 80 | Canada |
B | 7/10/2021 | 90 | Japan |
B | 5/11/2020 | 100 | US |
Expected Output
A | 30 | US |
A | 10 | India |
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)
Put your product condition within the rank(), like:
sum({<[Order date]={"=rank(if(Product='A', [Order date]))<=2"}>}Sales)
Hi,
This expression is working fine for me.
=sum({<[Order date]={"=rank([Order date])<=2"},Product={'A'}>}Sales)
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
Put your product condition within the rank(), like:
sum({<[Order date]={"=rank(if(Product='A', [Order date]))<=2"}>}Sales)
Thanks a lot it worked 🙂
Yes. Forgot to deselect.
Thanks for the help 🙂