Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to get a prescriber with maximum value (FirstSortedValue), independent of selections

Hi Guys,

I created a sample qvw (attached) in which I am trying to get the prescriber with maximum TRx. I am using FirstSortedValue function for satisfying the requirement.

However, I want this text to be independent of the prescriber selection. For instance, if P1, P2, P3 and P4 exist in the data and P4 is the prescriber with max TRx, how can I keep P4 as the top prescriber even when P1 and P2 are selected ?

PrescriberTRx
P1200
P2300
P3400
P4500

The top prescriber is obtained with expression

=FirstSortedValue(Prescriber, -Aggr(Sum(TRx), Prescriber))

Thanks,

Puneet.

1 Solution

Accepted Solutions
swuehl
MVP
MVP

Try

=FirstSortedValue({<Prescriber=>} Prescriber, -Aggr(Sum({<Prescriber=>}TRx), Prescriber))

View solution in original post

2 Replies
swuehl
MVP
MVP

Try

=FirstSortedValue({<Prescriber=>} Prescriber, -Aggr(Sum({<Prescriber=>}TRx), Prescriber))

Not applicable
Author

Thank you ! I had tried putting Prescriber= inside sum within aggr, but wasn't aware that firstsortedvalue accepts set analysis as an argument too.