Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

jduenyas
Not applicable

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

Tags (3)
9 Replies
Not applicable

Finding Max value

Create an expression :

FirstSortedValue(  OrderNo , -Amount )

regards

JJ

jduenyas
Not applicable

Finding Max value

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

Finding Max value

Maybe I miss something

Dimension :  OrderNo

Expression : Max(Amount)

JJ

jduenyas
Not applicable

Finding Max value

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

Thanks

Not applicable

Re: Finding Max value

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

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

jduenyas
Not applicable

Finding Max value

HEY THAT WORKED!

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

Toni_Kautto
Not applicable

Re: Finding Max value

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
Not applicable

Finding Max value

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

Re: Finding Max value

Hi Josh,

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