Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
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
ManuelRühl
Partner - Specialist
Partner - Specialist

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

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

Manuel Rühl
www.mamaconsulting.de
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.
ManuelRühl
Partner - Specialist
Partner - Specialist

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

Manuel Rühl
www.mamaconsulting.de