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

FirstSortedValue()_Multiple dimension values with same sort order

Dear all,

Following is the schema of my data.

EmployeeIDAgeConsumptionEducationGenderYearlyIncome

I want to show EmployeeID, Age, Gender in different text objects who have highest YearlyIncome. Previously I have data (Sheet 1) where there was only one Max value. I solved this problem by using FirstSortedValue() function. But in the current data (Sheet 2) I've two EmployeeID which are sharing the same maximum YearlyIncome. Please find the attached data set and qvw application. I solved this issue by following two approaches. Here are they-

Approach1: Concat(If(Aggr(Sum(YearlyIncome),EmployeeID)=vMaxSal,EmployeeID),',')

Approach2: Concat( {1<EmployeeID=P({<YearlyIncome={$(vMaxSal)}>})>} EmployeeID,',')

vMaxSal: =Max(Aggr(Sum(YearlyIncome),EmployeeID))

Although I've already solved the problem but still I've the following questions:

1) Can this problem be solved by using FirstSortedValue() in UI ? If Yes then how, if not then why No?

2) Can this problem be solved by using FirstSortedValue() in script ? If Yes then how, if not then why No?

3) Which approach is most effective way for huge amount of data, Approach 1 or Approach 2 ?

Please find the app and data set and also I'm attaching script in notepad. Thanks in advance.

Regards,

Joy

23 Replies
tresesco
MVP
MVP

One correction is needed.


=Concat(distinct Aggr(If(Sum({< Fakt = {'Fakt_A'}, Rok = {'2023'}>}Reg) = Max(total  <Area> Aggr(Sum({< Fakt = {'Fakt_A'}, Rok = {'2023'}>}Reg), Area, Brand)), Brand), Area, Brand), ',')

palo173
Contributor III
Contributor III

@tresesco I think, it is not right, because, for Area C, there should be B1 not B2.

palo173_0-1702557194225.png

 

tresesco
MVP
MVP

Check your field names, year or Rok ?

palo173
Contributor III
Contributor III

You are right, @tresesco , thank you.