Hi All,
I want to create following matrix report on SSRS.
Jan-07
Feb-07
Mar-07
Apr-07
May-07
Sales
Deviation
Sales
Deviation
Sales
Deviation
Sales
Deviation
Sales
Deviation
Here the Problem is i want calculate Deviation:
Deviation for Feb 07= Sales in Feb - Sales In Jan
Deviation For Mar 07 = Sales in Mar - Sales in Feb.
I don't know how to apply formula in Matrix:
Is anybody hele me?
Thank You.
Balwant Patel.
I do not think there is a striaght-forward formula for this since use of the Previous function is not supported in the Matrix data cell. You can either try calculating the deviation from the query itself, or implement it in the following manner using Custom Code:
Place the following VB.Net code in the code tab under report properties:
Shared Public PrevSales as Integer
Public Function CalDeviation(ColCount as Integer,CurSales as Integer) as Integer
Dim deviation as Integer
If ColCount=1 Then
PrevSales=CurSales
deviation=0
Else
deviation=CurSales-PrevSales
PrevSales=CurSales
End If
Return deviation
End Function
Then use the following call to the function in the textbox where you want to show the deviation:
=Code.CalDeviation(RunningValue(Fields!Month.Value,Count,"matrix1_Product"),Sum(Fields!Sales.Value))
Here, I have assumed the names Product, Month & Sales for the respective fields. Also, the Matrix Row Grouping is on Product & Column Grouping is on Month.
Hope this suits your purpose
-Aayush
Hi Aayush,
Thank you very much for your response...
I tried the code given by you...But when try to write the code in code window as below:
=Code.CalDeviation
the function .CalDeviation doesn't come up....
Thank you,
Regards,
Balwant Patel.
|||Hi Aayush,
The idea that you give me works now but it will not work when i view Report for Year Or Quarter .....
Please help me on this issue...
Thank you,
Regards,
Balwant Patel.
|||I guess it depends on your requirement, and how your Matrix is designed. What kind of functionality do you desire? Suppose you replace your Column Grouping from Month to either Year or Quarter, then it will work. If your column grouping changes on some condition etc, then it might be a bit more complicated.|||Hi Aayush,
Thank you very much for your response...
I did solve the problem....I applied following logic to solve the problem...In my Data Table I add Six Columns Like CurrMonthSales , PrevMonthSales , CurreQuarterSales , PrevQuarterSales , CurrYearSales , PrevYearSales...And then Updates these columns through Stored proc...And Then Based in Inscope Function...I Apply The Formula.
Thank you very much again..
Regards,
Balwant Patel.
No comments:
Post a Comment