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)
got the solution
sum({<[Order date]={"=rank(if(Product='A', [Order date]))<=2"}>}Sales)
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
got the solution
sum({<[Order date]={"=rank(if(Product='A', [Order date]))<=2"}>}Sales)
can you please help on this
https://community.qlik.com/t5/New-to-Qlik-Sense/Set-expression-help-combo-chart/m-p/1677449#M158328