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

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Show Group that has max quantity

Hi,

I have a question, i have a data like this:

Menu          Quantity          GroupName

A                    5                Group1

B                    10              Group1

C                    2                Group1

B                    1                Group2

A                    7                Group2    

i want to show  group name that has max quantity, Total quantity of group1 is 10+5+2 = 17 and Total of group2 is 1+7 = 8, So i want to show 'Group1' that has maximum total/sum quantity in a text Object. Can you show me the method ?

Thanks in advance.

1 Solution

Accepted Solutions
MayilVahanan

Hi

Try like this

=Concat(DISTINCT{<GroupName = {"=Sum(Quantity)=$(vMaxQuantity)"}>}GroupName,',')

where vMaxQuantity =Max(aggr(sum(Quantity), GroupName))

Hope it helps

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.

View solution in original post

17 Replies
Chanty4u
MVP
MVP

hi

can u attach the sample qvw..?

Thank you

Suresh

MayilVahanan

Hi

Try like this

=FirstSortedValue(GroupName, - Quantity)

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
tresesco
MVP
MVP

In the textbox:

=FirstSortedValue(GroupName, -Aggr(Sum(Quantity),GroupName))

sunilkumarqv
Specialist II
Specialist II

try like this

=sum({<GroupName={'Group1'}>}Quantity)/sum(TOTAL Quantity)

Not applicable
Author

Hi guys,

Thanks for all your help. But i have another problem, when there are two group that has same total quantity, let's say both Group1 and Group2 has total quantity 20. The result is -

Do you know why ?

Thanks

MayilVahanan

Hi

If both values are same, then Firstsortedvalue shows null value.

In that case, which value you need to show in textbox?

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
Not applicable
Author

Hi Mayil,

Is it possible to show both value, so the result will be 'Group1' and 'Group2'

thanks for your response

SatyaPaleti
Creator III
Creator III

Hi Indra,

Try with this

Max(aggr(sum(Quantity), GroupName))

Thank you,

Satya Paleti

tresesco
MVP
MVP

Just put Distinct like:

=FirstSortedValue(Distinct GroupName, -Aggr(Sum(Quantity),GroupName))

and don't worry about the synatx warning in red.