Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Tee_dubs
Contributor III

Peek Rangesum in Load script vs Rangesum Above in front end

I have an issue where my front end calculations and back end calculations are returning different results.

I am trying to get an accumulated sum of hours a machine has been operating.

My data is sorted firstly by Machine number and then my date (monthly)

LOAD SCRIPT:

if(previous(machine_id) = machine_id, rangesum(peek(accumHours), Hours),Hours) as accumHours

FRONT END:

Aggr(rangeSum(Above(Sum(Hours),0,RowNo())),([Date], (NUMERIC)))

I'm not sure where I am going wrong here.

 

Labels (2)
3 Replies
marcus_sommer

Your aggr() hasn't the needed dimensions of the machine and month (date may goes wrong if it's a key) and it missed an outer aggregation. Further quite often is an aggr() not needed for a cumulation because all needed dimensions are included within the object - therefore try just:

rangeSum(Above(Sum(Hours),0,RowNo(total)))

- Marcus

Tee_dubs
Contributor III
Author

Hi Marcus,

Thanks for the tip.  You are right, no need for the Aggr. Im getting the same (correct) result with or without the Aggr. Removing it helps clean up my code though, so thanks. 

The problem is the load script formula. 

Using the previous rangesum peek the result is very slightly less than the front end calculation. 

Any tips on the load script code?

 

Thanks

Tony 

marcus_sommer

It's difficult to guess what might be different and not working like expecting. I think I would include recno() and rowno() within the load and then checking it on the record-level within a table-box - maybe the sorting isn't correct or there are duplicates or missing values or some keys didn't match like expected (I assume that there are further selections applied) or something similar. In this way it should be visible what's wrong.

- Marcus