Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I have a situation where I need to accumulate a dynamic amount through the script. Considering in this example an accumulation of 3 in 3 days.
I need to add the current day, with the next two days, and so on until the last record.
Something similar to using RangeSum (Above(MyField,0,3)). However, I need to do it in the script.
Hi
may be like this
Load
RangeSum(Peek(Field), Peek(Field, -2), Peek(Field, -3)) as RangeSUM
Here you have to be careful about the load order : use order by Date desc ;
thank you very much for answering
i got it, but the only problem is that it's not a fixed range value.
There will be products that the interval will be, 3 other 2, another 15, it would have to be dynamic in some way
Hi
so you can adapt the mesure with a if statement
if(Product ='product1',
RangeSum(Peek(Field), Peek(Field, -2), Peek(Field, -3)) ,
if(product ='Product2',
RangeSum(Peek(Field), Peek(Field, -2), Peek(Field, -3),Peek(Field, -4),...,Peek(Field, -15))
))
as RangeSUM
Good Morning,
Thank you very much for replying, I was able to assemble the command dynamically. it looked like this:
FOR a=1 to NoOfRows('RangeTab')
LET vLead = Peek('LeadProduto', $(a)-1, 'RangeTab');
SET vCommand = 'RangeSum([qtd]';
For b=1 to ($(vLead)-1)
LET vCommand = '$(vCommand), Peek([qtd], - $(b))';
Next
LET vCommand = '$(vCommand)) as RangeSum';
NEXT