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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How to find a variable based on max date and max sales (2 conditions) without any preloading

Hi all,

I have the table as follows:

datefruitsales
07-12-18papaya99
07-12-18apple926
07-12-18orange852
08-12-18papaya961
08-12-18apple252
08-12-18orange207
09-12-18papaya642
09-12-18apple452
10-12-18orange280
11-12-18papaya129
12-12-18apple751
12-12-18papaya301
12-12-18orange19

 

I would want the fruit name with the most sales for the latest date. In this case, 'apple' should be my answer.

 

Thanks!

Labels (3)
1 Solution

Accepted Solutions
OmarBenSalem

Create a KPI with this measure:

 

FirstSortedValue(fruit, -aggr( max ({<date={"$(=max(total date))"}>} sales),date))

 

Result:

Capture.PNG

View solution in original post

2 Replies
OmarBenSalem

Create a KPI with this measure:

 

FirstSortedValue(fruit, -aggr( max ({<date={"$(=max(total date))"}>} sales),date))

 

Result:

Capture.PNG

Anonymous
Not applicable
Author

Thanks Omar