Script for distinct count in automated indiactor in peromance analytics
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
We have two tables: Division and Activity. The Division data is being used within the Activity table as a list-type field (List Collector).
To determine the number of divisions associated with each activity, we implemented the following approach:
- Created a Performance Analytics automated indicator
- Added a script to calculate the count of divisions selected in the list field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Your 'if' will only return the first one and doesn't do anything after that. However, that may not even be the issue. You mention 'script is not working'. But you don't mention what isn't working. Doesn't it return anything? Too much? Too little?
Depending on what isn't working, what you are getting returned and what you are expecting to return, something like this could help:
function execute() {
var divisionSysId = current.getValue('sys_id');
var gaActivity = new GlideAggregate('x_cenll_strategi_0_activity');
gaActivity.addQuery('division', 'CONTAINS', divisionSysId);
gaActivity.addAggregate('COUNT');
gaActivity.query();
if (gaActivity.next()) {
return parseInt(gaActivity.getAggregate('COUNT'), 10);
}
return 0;
}
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark