calculation result is in text, is there a way to achieve it in numerical format.
Hello
I am using the below formula in calculation to display the Hours & Minutes from a duration field of related items. The result of the calculation is a text format HH:MM. Is there a way it could give me a number format hh.mm so that I can use the calculation field in reports to use as SUM.

var asMin= @Sum of Duration*60;
var hrs = parseInt(asMin/60);
var min = Math.round(asMin % 60);
hrs + ":" + min

SCENARIO: So Projects (Level1) are connected to Deliverables (Level 2) and timesheets (level 3) are connected to Deliverables. the below calculation is on level 2 which pulls the data from related level 3 items. What I want to do is display a SUM of hh.mm on Level 1 from related Level 2 field. But since the result of the below calculation is text it is not allowing me to calculate the sum.
Is there another way of doing it if you understand my above scenario ?
Regards,
Jayraj

Hi Jayraj,
On level 2 you can simply use
@sum of duration
The result is a number like 10.5 (= 10 hours 30 minutes)
The on level 1:
@sum of calculation field level 2
If you really need to show it on level 2 as text and not as number you need on level 1 a for loop which pulls the numbers from the level 2 strings and parses them to numbers:
var l2 = @all of calculation field level 2;
hrs = 0;
min = 0;
for(var i = 0; i < l2.length; i++){
hours = Number( l2[i].split(":")[0])  0;
minutes = Number(l2[i].split(":")[1])  0;
hrs += hours;
min += minutes;
};
var hrs = hrs + parseInt(min/60);
var min = Math.round(min % 60);
hrs + ":" + minRainer
Please sign in to leave a comment.
Comments
3 comments