How to get category with maximum and minimum incidents using glideaggregate
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2024 04:35 AM
Hi All,
I need help to get the category name and count which has maximum and minimum incidents. We can get the count of incidents under all the categories but here i want only max and min count and category.
Thanks,
Vidyashree
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2024 07:46 AM
Hi @Community Alums
Thank you for your reply.
The result i am expecting is different. For example if the database category is having maximum number of incidents it should display category name along with the count. Same for category with minimum incidents.
In the below screenshot i want only Inquiry and Database to be displayed
Thanks
Vidyashree

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2024 09:53 AM
Hi @Vidya Shree ,
Please try below script this will give you maximum and minimum Incident Category
var count=new GlideAggregate('incident');
count.addAggregate('MAX','category');
count.addAggregate('MIN','category');
count.setGroup(false);
count.query();
while(count.next()){
gs.print(count.getAggregate('MAX','category'));
gs.print(count.getAggregate('MIN','category'));
}
Please mark my answer correct and helpful if this works for you
Thanks and Regards
Sarthak