Qlik Community

App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

Announcements
Now Live: Qlik Sense SaaS Simplified Authoring – Analytics Creation for Everyone: READ DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
ayseayse
Contributor II
Contributor II

First sorted value equality condition

I used first sorted value to make my calculation, My aim was to take max of total, concatenate reasons while mat is same and print tur which corresponds to max total.

However there may be equality of total for different inputs(rows). In such cases, I would like to create a priorization among turs. If there is equality in among totals  "bi" should be first to print then, "ek"and then "ka".

So below case instead of - , "bi" should be printed.

p.s.In case are two distinct line where tur and the total are the same,  it should print tur itself in instead of "-"

 

 

 

Raw:
load
tur,
mat,
total,
reason

From mysource;


Calculation:
LOAD
FirstSortedValue(tur,-total,1) as "tur1",
mat as mat1,
max(total) as total1,
concat(reason) as reason1

Resident Raw
Group by mat

4 Replies
mruehl
Creator III
Creator III

In this case FirstSortedValue(DISTINCT tur,-total,1) as "tur1",

worked for me because the alphabetical order BI / EK / KA matches.

ayseayse
Contributor II
Contributor II
Author

Unfortunately, it did not work at my local, it brought  "ka" instead of "bi".  From what understood from other community posts is that distinct was bringing random inputs.

ayseayse
Contributor II
Contributor II
Author

Unfortunately, it did not work at my local, it brought "ka" instead of
"bi". From what understood from other community posts is that distinct was
bringing random inputs.
mruehl
Creator III
Creator III

@ayseayse Did you find a solution?
I tried several approaches but nothing worked...