Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Problem with FirstSortedValue()

Hi All

I am trying to get the count of incidents using the firstsortedvalue. I have filters for Category and the date. Below is the sample data.

Also, I can not have this at the script as the filters are dynamic.

      

IDGroup IDIncident GradeIncident TimeIncident IDIncident DateIncident Date ValueCategory
180364476A00:00:0095023049415239/6/2013Public
280364476A12:24:39957484684156410/17/2013Public
380364476A00:00:0098735114417334/4/2014Private
480364476A+00:00:161042660444196011/17/2014Public
580364476A+00:00:18107288827421184/24/2015Private
680364476A+00:00:311085080604232711/19/2015Private
780364487B00:00:0095023184416461/7/2014Public
880364487C12:24:3995748603416872/17/2014Public
980364487C00:00:0098735249418568/5/2014Private
1080364487B00:00:16104266179420833/20/2015Public
1180364487B00:00:18107288962422418/25/2015Private
1280364487C00:00:311085081954245012/1/2015Private

If I select Public and date '12/31/2014' I should see

    

80364476A+10426604411/17/2014Public
80364487C     957486032/17/2014Public

If I select just the date '12/31/2014' and nothing from the Category, then

    

80364476A+10426604411/17/2014Public
80364487C987352498/5/2014Private

Thanks for all the help.

1 Solution

Accepted Solutions
sunny_talwar

See if the attached is helpful

View solution in original post

18 Replies
Anonymous
Not applicable
Author

HI,

You are saying you select the date '12/31/2014' and you want as a result dates 11/17/2014, 2/17/2014 or 8/5/2014.

How are you matching those dates?

Please give more details.

Not applicable
Author

Get the most recent one. So, in this case incident date less than 12/31/2014.

sunny_talwar

Would you be able to share the sample you might be working and testing on? I was wondering how are you making selection in your date field.

Not applicable
Author

Using a variable for the date. Will try to upload a sample QVW.
Thanks

Anonymous
Not applicable
Author

and why do you get two lines of results? Is it your need?

You don't have to use firstsortedvalue for your need.

You should just sort your table on the Incident Date field "sort by numeric value descending" and in Dimension limits you check "Restrict which values are displayed using the first expression" -> Show only -> First -> 2

sunny_talwar

Check out the attached:

No selection in Category and Date = 12/31/2014

Capture.PNG

Category = Public and Date = 12/31/2014

Capture.PNG

Not applicable
Author

Thanks so much for the reply. I am trying to get the count by the Incident grade (have some others like region etc). In the below case, I need to see

  

Incident Grade            Count
A1
C1

1.png

sunny_talwar

Not sure, are we talking about the same requirement as above? or the requirement changed?

Not applicable
Author

Sorry for the confusion. I used your code to get the count by grade (a different report).

Thanks