Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Announcements
QlikWorld 2020: Join us May 11 - 14, 2020 in Phoenix, AZ. Register early and save $400. Learn More
Highlighted
Not applicable

Displaying a specific record by finding the max of a field

I want to do this in a text object.

How do I find the max value of a field, then display the corresponding value of that record under another field?

Ex: Find max(sales), then display the salesman responsible for that sale.

How about the second-place salesman?

Tags (1)
1 Solution

Accepted Solutions
MVP
MVP

Re: Displaying a specific record by finding the max of a field

You can probably use Firstsortedvalue() for this, maybe like

=FirstSortedValue( salesman, -aggr( sum(sales), salesman))

and for second place

=FirstSortedValue( salesman, -aggr( sum(sales), salesman),2)

View solution in original post

3 Replies
MVP
MVP

Re: Displaying a specific record by finding the max of a field

You can probably use Firstsortedvalue() for this, maybe like

=FirstSortedValue( salesman, -aggr( sum(sales), salesman))

and for second place

=FirstSortedValue( salesman, -aggr( sum(sales), salesman),2)

View solution in original post

Not applicable

Re: Displaying a specific record by finding the max of a field

Thanks!  This is what I needed.  Just one question... What is the - operator in front of aggr for?

MVP
MVP

Re: Displaying a specific record by finding the max of a field

It just negates the expression results of the aggr() function (you could of course also write: aggr( -sum(sales),salesman)

The FirstSortedValue() function returns the salesman with the smallest sort weight, if you want to return the largest / max(sales), use a negative sum of sales.

Hope this makes sense,

Stefan