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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
mschatt
Contributor
Contributor

Show record with max field value using aggregation

Hello Experts,

I have situation: I want to find record with max value of field "prediction sum". I am using the aggregation: aggr(max(prediction_sum),prediction_for). Field "prediction_for" has one value across the table. After aggregation I have one record, but value of the field "probability" is different than in source table. Why? (pic below)

problem.PNG

Thanks in advance

Labels (1)
1 Solution

Accepted Solutions
tresB
Champion III
Champion III

Use calculated dimension like:

=Aggr(FirstSortedValue( probability,  -prediction_sum), prediction_for)

View solution in original post

6 Replies
tresB
Champion III
Champion III

"probability" is a field or you are using some expression to create it?

MK_QSL
MVP
MVP

May be

FirstSortedValue(probability, aggr(max(prediction_sum),prediction_for)

mschatt
Contributor
Contributor
Author

Probability is a field. I am loading it form datasource.

tresB
Champion III
Champion III

Try in your chart like:

FirstSortedValue( Aggr(probability, prediction_for), -aggr(prediction_sum, prediction_for))

if this doesn't work, try to share your sample qvw.

mschatt
Contributor
Contributor
Author

In attachment is an example qvw. I thought that when I use aggregation it will show the one record with max field and other fields related to this value. Something is missing?

tresB
Champion III
Champion III

Use calculated dimension like:

=Aggr(FirstSortedValue( probability,  -prediction_sum), prediction_for)