1 Reply Latest reply: Aug 24, 2013 3:30 PM by whiteline _

Peek function used like rangesum in script

Is it possible to use the peek function in the script similar to the rangesum(above()) function?

I have the following formula in a pivot and need to transfer the same functionality to the script.

```
if(rangesum(above(sum(if([Hours Code]='',[Paycor Hours])),0,RowNo()))<=40,0,

if(rangesum(above(sum(if([Hours Code]='',[Paycor Hours])),1,RowNo()))>40,
sum(if([Hours Code]='',[Paycor Hours])),
if(rangesum(above(sum(if([Hours Code]='',[Paycor Hours])),1,RowNo()))<=40,
rangesum(above(sum(if([Hours Code]='',[Paycor Hours])),0,RowNo()))-40))))

+

sum(if([Hours Code]='OT',[Paycor Hours]))
```

This formula is calculating Overtime over a week. I need the script to look at all the days of the previous week to current record, and then change the formula weather 40 hours has been reached. This needs to then be reset to start the process over for each new week. This will give me several fields based on each days specific row.

overtime

standard time

field standard time

field overtime

night premium field overtime

night premium field overtime

Since the night premium is specific to the day that it was worked on, I need this function to calculate if at that time they had reach overtime or not. The final result is a summary for each employee, hence why I need this done on the script level

• Re: Peek function used like rangesum in script

Hi, Marc.

I would say like above, cause the rangesum is still useful in this case.

Of course, you have to preapare a table properly sorted and aggregated.

Then create a separete field for calculating rolling sum with peek -ing the same field, reseting the accumulation each time the new week starts.