Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
jduenyas
Specialist
Specialist

Finding Max value

Hi all

How do I find which order has the max value?

OrderNoAmount
ABC125
BCD325
ABC541
DEF125
DEF135
ABC438
BCD223
EFG123

The dimension is against a SalesPerson

I thought that Max(Sum(aggr(Amount,OredrNo))) will do but it does not.

Thanks in advance

Josh

9 Replies
Not applicable

Create an expression :

FirstSortedValue(  OrderNo , -Amount )

regards

JJ

jduenyas
Specialist
Specialist
Author

I must have messed the question.

I am looking for the Max TOTAL value (sum) of an order not  the Order that has the Max Value.

Your answer, for sure,  will sure help me elsewhere.

Meanwhile, would you know how to extract the Max value for the orders

Not applicable

Maybe I miss something

Dimension :  OrderNo

Expression : Max(Amount)

JJ

jduenyas
Specialist
Specialist
Author

But I do not wish to show OrderNo in the dimension side.

Thanks

Not applicable

Did you try adding in the Sales person to the Aggr function?

Max(aggr(Sum(Amount),SalesPerson,OrderNo))

jduenyas
Specialist
Specialist
Author

HEY THAT WORKED!

= Max(aggr(sum(Amount),OrderNo))

ToniKautto
Employee
Employee

First of all you need to keep in mind that aggr() is defined as show below. This means that it must include an expression and then the dimensions over which the expression is calculated. If you are looking for the max value in your dimensions you simple right something like aggr(max(fieldName), dimension1, dimension2, dimension3)

aggr ( [ distinct | nodistinct ] [{set_expression}]expression {, dimension} )

Secondly you need to keep in mind that aggr will return a set of values, so if the aggregation expression does not return a single value you might need put the aggr() in a sum() for example to get the aggr set total sum.

The final answer to your question depends on what your data model looks like in relation to the chart you are trying to accomplish. You are probabaly loking for a construction like max(aggr(sum(fieldname), dimension1, dimension2, dimension3)) or aggr(max(fieldname), dimension1, dimension2, dimension3))

jduenyas
Specialist
Specialist
Author

Thank you Toni. As per my previous reply to all the formula = Max(aggr(sum(Amount),OrderNo)) works correctly.

Your explanation that aggr() returns a set is valuable information that I should keep in mind.

PS I like your icon (the hat). Creative and unique.

Thanks

Not applicable

Hi Josh,

FirstSortedValue(  OrderNo , -aggr(sum(Amount)) )