Hello all,
I have a requirement in webi report where I have to calculate "previous meter reading".
I have "meter reading" in the database. Example: if I select station no: 04, Date from: 2 May 2014 and Date to: 2 May, 2014 and Product = 1. If this criteria has only one "report #"(field in database) then the previous and current meter readings give correct values. But if this criteria has 2 "Report #" like,
abc and xyz, then abc returns correct previous and current meter readings but xyz returns wrong prvious meter reading.(I am expecting to see current meter reading of abc as previous meter reading of xyz), but I get previous meter reading of xyz same as previous meter reading of abc.
The calculation that I am using for prev meter reading in universe(3.1) is :
(select top 1 b.STOCK_READING
from dbo.SITE_SALES_SUMMARY a
INNER JOIN dbo.PRODUCT_GROUP_SALES_SUMMARY b ON a.SITE_SALES_SUMMARY_ID=b.SITE_SALES_SUMMARY_ID
INNER JOIN dbo.PRODUCT_GROUP c ON (b.PRODUCT_GROUP_ID=c.PRODUCT_GROUP_ID)
where 1=1
AND a.STATION_ID = dbo.SITE_SALES_SUMMARY.STATION_ID --site-id
and c.PRODUCT_GROUP_ID=dbo.PRODUCT_GROUP.PRODUCT_GROUP_ID--product group code
and CAST(a.CLOSE_TIME as date) <= dateadd(dd,-1,CAST(dbo.SITE_SALES_SUMMARY.CLOSE_TIME as date))-- date
order by a.CLOSE_TIME DESC)
and then in tables I select Sales Summary and Product group and this parses fine in the universe. I am not sure why the 2nd Report# returns wrong previous meter readings.
Thanks
N