- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2023 03:41 AM
Hello Everyone,
I have created 2 Tables and the first table impact calculation and second one is overall impact. I would like to calculate total of <10 min field from the first table and then populate in the second table overall impact table in total 10 min field.
In the first table <10 min field is choice and in the second table total 10 min field is integer.
this is my script
I would like to calculate total of <10 min field and then populate in the overall impact table.
Can anyone help me out with script or point me in the right direction it would be greatly appreciated.
Thank you
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2023 03:12 AM - edited 10-20-2023 03:30 AM
Hello,
I came across the below post. It appears that if you aren't using "addGroup" with SUM aggregate, it still tries to group by a value in the background. (It groups and sums the same values together, so all your 1s, 2s, 3s etc if you output these throug a while loop)
(function calculatedFieldValue(current) {
var total = 0;
// Create a GlideAggregate query to calculate the sum of the "u_10_min" field in the x_1002836_f64_c table
var aggregate = new GlideAggregate('x_1002836_f64_c');
aggregate.addAggregate('SUM', 'u_10_min'); // Calculate the SUM of the "u_10_min" field
aggregate.setGroup(false);
aggregate.query();
if (aggregate.next()) {
total = aggregate.getAggregate('SUM', 'u_10_min');
}
return total;
})();
So to fix it you need to add the line "aggregate.setGroup(false);" into your script
Thanks 🙂

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2023 03:12 AM - edited 10-20-2023 03:30 AM
Hello,
I came across the below post. It appears that if you aren't using "addGroup" with SUM aggregate, it still tries to group by a value in the background. (It groups and sums the same values together, so all your 1s, 2s, 3s etc if you output these throug a while loop)
(function calculatedFieldValue(current) {
var total = 0;
// Create a GlideAggregate query to calculate the sum of the "u_10_min" field in the x_1002836_f64_c table
var aggregate = new GlideAggregate('x_1002836_f64_c');
aggregate.addAggregate('SUM', 'u_10_min'); // Calculate the SUM of the "u_10_min" field
aggregate.setGroup(false);
aggregate.query();
if (aggregate.next()) {
total = aggregate.getAggregate('SUM', 'u_10_min');
}
return total;
})();
So to fix it you need to add the line "aggregate.setGroup(false);" into your script
Thanks 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2024 06:49 AM
Hello ,
I currently have two tables. I want to calculate the total of the "< 10 min" field for records with the same reference number in the first table ('x_1002836_f64_c'). I would like to display this total in the 'Total of < 10 min' field in the second table. In the first table with the SAME reference table total of "< 10 min" should be in the second table in total 10min.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2023 05:31 AM
Huge Thank you Rhodri. Working now. 🙂