Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

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

night premium 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

1 Reply
whiteline
Master II
Master II

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.