Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

gameoverzx
New Contributor III

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 (4)
1 Solution

Accepted Solutions
OmarBenSalem
Esteemed Contributor

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

Create a KPI with this measure:

 

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

 

Result:

Capture.PNG

2 Replies
OmarBenSalem
Esteemed Contributor

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

Create a KPI with this measure:

 

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

 

Result:

Capture.PNG

gameoverzx
New Contributor III

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

Thanks Omar
Community Browser