Last Month vs Current Month
Hi All, I was able to achieve the first 3 items below. item 1 and 2 is created thru query. While item 3, I able to achieved using FIRST() and LAST() function.  Now, my problem is for the Item 4 to 6. I don't have any idea on how to achieve this using expression. Could someone show me how to do this? Thanks in advance.
July 26th, 2012 11:59pm

To help you, please tell us which are the columns of your dataset. You probably could achieve it in SQL Server.
Free Windows Admin Tool Kit Click here and download it now
July 27th, 2012 2:34am

I this query for the Item 1 and 2. Select 'Current Year Sales Amt' Names, shopT.ShopTypeName, YEAR(sales.BizDate)Y, MONTH(sales.BizDate)ID, DATENAME(MONTH,sales.BizDate)M, SUM(sales.PaidAmt) sales From TransSku sales Inner Join ConShop shop On sales.ShopID = shop.ShopID Inner Join ShopType shopT On shop.ShopTypeID = shopT.ShopTypeID Where YEAR(sales.BizDate) = YEAR(@Date)--@Year And shop.StoreID = 106 Group By shopT.ShopTypeName, YEAR(sales.BizDate), MONTH(sales.BizDate), DATENAME(MONTH,sales.BizDate) UNION Select 'Previous Year Sales Amt' Names, shopT.ShopTypeName, YEAR(sales.BizDate)Y, MONTH(sales.BizDate)ID, DATENAME(MONTH,sales.BizDate)M, SUM(sales.PaidAmt) sales From TransSku sales Inner Join ConShop shop On sales.ShopID = shop.ShopID Inner Join ShopType shopT On shop.ShopTypeID = shopT.ShopTypeID Where YEAR(sales.BizDate) = YEAR(@Date) - 1 And shop.StoreID = 106 Group By shopT.ShopTypeName, YEAR(sales.BizDate), MONTH(sales.BizDate), DATENAME(MONTH,sales.BizDate) Order By shopT.ShopTypeName, MONTH(sales.BizDate)
July 27th, 2012 2:46am

Any help please.. Thanks
Free Windows Admin Tool Kit Click here and download it now
July 29th, 2012 11:11pm

If you use SSRS 2008 R2 or later, please try with 'Lookup' function. Create a seperate dataset which returns Year and Month wise values. Using Lookup function pass the appropriate year and month to get prior year or month data. Do the calculation in textbox expression. Hope this helps you..Regards, Senthil
July 30th, 2012 12:52am

If you have 2008 R2 then you might be able to use the Lookup function for 4 and 5. You'll probably need to create a YearMonth key in your dataset so you can refer to it inside the lookup(), maybe add the #4 and #5 lookup keys to the row as well in the sql so add something like select convert(varchar,GETDATE(),112)/100 as YearMonthKey , convert(varchar,dateadd(MONTH,-1,GETDATE()),112)/100 AS CurrYearPrevMonthKey , convert(varchar,dateadd(YEAR,-1,GETDATE()),112)/100 AS PrevYearCurrMonthKey to your dataset (null the CurrYearPrevMonthKey and PrevYearCurrMonthKey rows in your Previous year amt select query). Or add them to your date dimension table in your reporting database if they'll be useful elsewhere So for for #5 your expression would be similar to =Sales.Value - Lookup(Fields!CurrYearPrevMonthKey.Value, Fields!YearMonthKey.Value,Fields!Sales.Value,"datasetname") This'll subtract the Sales.Value for the row where the YearMonthKey matches the prev month from the current row. Do the same thing with #4 but use the PrevYearCurrMonthKey instead I'm not sure what you want to accomplish with 6
Free Windows Admin Tool Kit Click here and download it now
July 30th, 2012 1:02am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics