- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hello Team,
I have an indicator and a breakdown but indicator score is showing complete count and not following the filter applied by breakdown.
For eg: I created a TopN metric using a Script and I used this script in breakdown source and I was able to get the TopN elements. But the Indicator total is still showing the complete count and not just the Top10 count.
Any suggestion on how to restrict Indicator count to Top10 count.
Thanks in advance
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi Buddy,
The breakdown does not filter or limit the indicator score. The indicator always calculates against the full data set. The breakdown only controls how that result is split or displayed afterward. So even though your Top-N breakdown shows only the top 10 elements, the indicator total will still reflect the complete count.
That’s why you’re seeing the full number on the indicator, not just the Top-10.
If you want the indicator total to show only the Top-10 count, the restriction has to be applied at the indicator level, not in the breakdown.
What usually works best:
Put the Top-10 logic directly into the indicator’s script, so it only counts records belonging to the Top-10.
Or create a separate indicator specifically for “Top-10 only” and use that wherever you need the restricted total.
Using a breakdown alone won’t ever change the indicator total — it only affects how the data is sliced for visualization.
@venori26 Please mark Accepted Solution and Thumbs Up if you found Helpful 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi Buddy,
The breakdown does not filter or limit the indicator score. The indicator always calculates against the full data set. The breakdown only controls how that result is split or displayed afterward. So even though your Top-N breakdown shows only the top 10 elements, the indicator total will still reflect the complete count.
That’s why you’re seeing the full number on the indicator, not just the Top-10.
If you want the indicator total to show only the Top-10 count, the restriction has to be applied at the indicator level, not in the breakdown.
What usually works best:
Put the Top-10 logic directly into the indicator’s script, so it only counts records belonging to the Top-10.
Or create a separate indicator specifically for “Top-10 only” and use that wherever you need the restricted total.
Using a breakdown alone won’t ever change the indicator total — it only affects how the data is sliced for visualization.
@venori26 Please mark Accepted Solution and Thumbs Up if you found Helpful 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Can you please share any TopN script (indicator)? @Matthew_13
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Scripted Indicator returns Top-10 total
Use this in a Scripted Indicator Source (or wherever your PA indicator script expects you to return a single numeric score).
(function() {
var TABLE = 'incident';
var GROUP_FIELD = 'assignment_group';
var N = 10;
// last 30 days
var start = gs.daysAgoStart(30);
var end = gs.nowDateTime();
// 1) Find Top N groups by count
var top = []; // array of sys_id strings for top groups
var gaTop = new GlideAggregate(TABLE);
gaTop.addQuery('sys_created_on', '>=', start);
gaTop.addQuery('sys_created_on', '<=', end);
gaTop.addNotNullQuery(GROUP_FIELD);
gaTop.addAggregate('COUNT');
gaTop.groupBy(GROUP_FIELD);
// Sort by count desc
gaTop.orderByAggregate('COUNT');
gaTop.setLimit(N);
gaTop.query();
while (gaTop.next()) {
top.push(gaTop.getValue(GROUP_FIELD));
}
if (top.length === 0) {
return 0;
}
// 2) Count only records in those Top N groups
var gaTotal = new GlideAggregate(TABLE);
gaTotal.addQuery('sys_created_on', '>=', start);
gaTotal.addQuery('sys_created_on', '<=', end);
gaTotal.addQuery(GROUP_FIELD, 'IN', top.join(','));
gaTotal.addAggregate('COUNT');
gaTotal.query();
var total = 0;
if (gaTotal.next()) {
total = parseInt(gaTotal.getAggregate('COUNT'), 10) || 0;
}
return total;
})();
