
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
FirstSortedValue for the two same values
Hello,
This is my formula for the age for employees. I need to to put the biggest age interval in the title.
FirstSortedValue(Age,-aggr(max(aggr(avg(aggr(sum([HeadCount]),[Period], Age)), Age)), Age))
My problem is that for particular moment I have two ages(55-60 and 60-65 ) that have exactly the same number of people(33 people). Probably because of that my formula doesn't show anything. For all other cases it works fine. How should I improve it and say to show youngest age for example if there are two groups with the same number of people?
Thanks a lot in advance!
Accepted Solutions


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Two options I know of:
1. Add the DISTINCT keyword to FirstSortedValue and let Qlik choose. I think it's the first one in load order.
2. Add some small bias to your FirstSortedValue parameter 2. For example, -(Age * .001)
I realize Age is a string you may have to do something like -(SubField(Age,'-',1) * .001)
-Rob
http://www.easyqlik.com
http://masterssummit.com
http://qlikviewcookbook.com


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Have a look at:
For approaches to deal with the "Ties return null" issue for FirstSortedValue()


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Two options I know of:
1. Add the DISTINCT keyword to FirstSortedValue and let Qlik choose. I think it's the first one in load order.
2. Add some small bias to your FirstSortedValue parameter 2. For example, -(Age * .001)
I realize Age is a string you may have to do something like -(SubField(Age,'-',1) * .001)
-Rob
http://www.easyqlik.com
http://masterssummit.com
http://qlikviewcookbook.com

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
thank you!
Could you please show in the formula how it should be?
I tried both distinct and (SubField(AgeBand,'-',1) * .001) and it is not working.
Maybe I'm not using it correctly?
Thanks a lot in advance!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you!! ! It worked! I had to add distinct to the age(first parameter).
