Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
I need have date ,product,region and district as fields in my script.
Now i need to get the previous volume for each date based on product.How can i achieve that??
Kindly help.
Regards,
Reena
Hi Reenaabraham,
Try Peek() or Previous function.
Check this post: Peek() or Previous() ?
I tried it.but it is coming based on the date.i need to get it based on both product basis and also by date wise.
Provide some sample data with expected output to get the exact solution
you need to use Peek('fieldname', RecNo()-1,'table') BUT you must sort the input table first in the order you need it so that the previous row always contains the values you want to compare.
Hi,
use Peek() or Previous() as indicated by the other users, use it ordering the data in the order you wish
For example somthing like this
LOAD product,region, district, date, volume, peek(volume) as previous_volume
FROM yoursource
ORDER BY product asc, date asc
Eventually use a GROUP BY too, it depends from your data.
S.
Hi All,
Attaching the sample data for your reference.
You seem to have multiple products on a single date. What exactly is your expected output from the same you have provided?
Hi i need to get the previous date value for each product.
Date Product Volume Output
01-01-15 ABC 100 0
01-01-15 BCA 200 0
01-01-15 ACB 400 0
02-01-15 ABC 250 100
02-01-15 BCA 50 200
02-01-15 ACB 150 400
02-01-15 HIJ 150 0