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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
arpitkharkia
Creator III
Creator III

Obtain field with maximum value

Please consider the following example:

CategoryValue
A10%
B20%
B22%
A20%

I will be loading the above table directly into Qlik. What I want is to first have an average of Value so that the following table is obtained:

CategoryValue
A15%
B21%

from this now I have to find the name of the category having the highest value. So, from table1 I have to obtain Category B as the answer.

How to perform the above using Set Analysis or/and Back-end scripting?

1 Solution

Accepted Solutions
lironbaram
Partner - Master III
Partner - Master III

hi

for finding the Category with the highest avg

use this expression :

=FirstSortedValue(Category,-aggr(avg(Value),Category))

View solution in original post

6 Replies
lironbaram
Partner - Master III
Partner - Master III

hi

for finding the Category with the highest avg

use this expression :

=FirstSortedValue(Category,-aggr(avg(Value),Category))

Anil_Babu_Samineni

Why can't you create Simple

Num(Avg(Value),'##,##0%')

Capture.PNG

For second one try like below

For Max =FirstSortedValue(Category,Aggr(Num(Avg(Value),'##,##0%'),Category))

For Min =FirstSortedValue(Category,-Aggr(Num(Avg(Value),'##,##0%'),Category))

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
HirisH_V7
Master
Master

Hi,

Check this

=Num(rangeavg(Aggr(Above(sum(Value),0,rowno()),Category))/Count(Category),'#,##0%')

As Exression in chart  or Table.

-Hirish

HirisH
MK_QSL
MVP
MVP

=FirstSortedValue(Distinct Category,-Aggr(Avg(Value),Category))

or

=FirstSortedValue(Category,-Aggr(Avg(Value),Category))

and if you have more than one category having same average.. you can use below to get more than one category..

=Concat({<Category = {"=Rank(Avg(Value))=1"}>}DISTINCT Category)

surendraj
Specialist
Specialist

Hi Arpit,

I tried this,Its working fine.

=FirstSortedValue({<Category>}Category,-Aggr(max({<Category>}Value),Category))


By using this you can achieve Category B as the answer even if you made the selection on Category it won't change.


--Surendra

arpitkharkia
Creator III
Creator III
Author

Thank you everyone for the help!