### Post

3 followers Follow

# calculation of hours performed

Hi everyone,

I have an App that contains the calendars of all courses with Course, Start Date, End Date and Duration (End minus Initial) Calculated.
I would need a calculation on the item that I calculate the hours worked up to that date.

Thank you

Claudio Calabrò

Hi Claudio,

what do you mean by "hours worked up to that date."? What are the parameters?

Rainer

```App A Course
App B Course (related App A), Star dates, End Date, Hour, Progressive.

I need to calculate the Progressive field.

I enclose a table for clarity```

Sorry, but not sure if I understand you correctly. Do you want to create a table in App A with data from all related items in App B?
If so do you have already a calculation with a for loop? If so you can do something like

var course = @all of course;
var start  = @all of start date;
var end = @all of end date;
var hrs = @all of hours;
var rows = [];
var prog = 0;
for( i = ....){
prog += hrs[i] || 0;
rows.push([course[i],start[i],end[i],hrs[i],prog].join(" | ")];
};

```maybe I explained myself badly.
I would like to know how to calculate the progressive field in APP B.```

Hi,

I tried to use the code you showed me but I can not see how I would like to. The progressive field should display 4 8 12 16 20 while I currently display 20 4 12 8 16. Below the screenshot of the code and the result

Claudio Calabrò 1 vote

Hi Claudio,

For implementing this you need to

1) Create a new calculation field in app A which consolidates all the App B data as json.

2) While consolidating the data you need to sort all the related app B items and calculate the progressive value and store in the same json.

3) After that, you need to create a new calculation field in app B and use the above consolidated json and display the progressive field.

You need to do a couple of calculations but using the above steps you can achieve this.

- Bajarang

Bajarang 1 vote

Hi Claudio,

sorry, I had a typo in my code: instead of a dot between hrs[i]  and prog there must be a comma. Means for your code: Replace the dot between Ori[i] and prog with

+ " | " +

Also there are 2 mistakes in your code:
a) When you use @all of with nulls you should call the array elements for the arrays with nulls with [i][0], not only [i].
b) In the IF-line in your screenshot the { bracket for the if clause is in the wrong place. It must be directly behind the closing ) of the if clause: if(.... "Tutto"){

@Bajarang

Yes, JSON is my preferred tool for calculation fields too, it has so many advantages. But I think it's too sophisticated for beginners. And I think Claudio will get the right progressive numbers when he updates his code.