Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Field corresponding to max(value)

Hi all,

I have a question.

Ths is my database

ModelColorSum(Qty)
A110
A215
A33
B16
B410
C14
C38
C52

I would like to have a second table where for each model I see the color with max(Sum(Qty))), i.e.:

ModelColor
A2
B4
C3

where "Model" is the dimension and "Color" is the expression (equals to the color corresponding to max of Sum(Qty) for each model).

Could anyone please help me?

Many thanks!

4 Replies
Not applicable
Author

Hi Elena,

please see the attached example.

Good luck!

Rainer

Not applicable
Author

hi,

use the following code

tab1:

ModelColorSum(Qty)
A110
A215
A33
B16
B410
C14
C38
C52



from ......;

tab2:

load Model,max(Color) resident tab1 group by Model;

thanks

Not applicable
Author

Sorry, maybe I was not so clear.

Where I wrote "this is my database" maybe I have to write "this is my straight table" (where "Model" and "Color" are dimensions and "Sum(Qty)" is the expression). Starting from this table I would like to have another one with "Model" as dimension and "Color" as expression (where the value corresponds for each model to the color of max of Sum(Qty)).

Isn't it possible to do it into the expression chart instead of into the script?

Not applicable
Author

Hi Elena,

what you need is "FirstSortedValue" as expression.

Good luck!

Rainer