Custom Code in SSRS 2008

Hi,
I am trying to write Custom Code in SSRS for Age Calculation for two requirements in the same report,But report is giving error #Error in expression with my below code.
whole logic is same for both but only two lines are different,Do i need create two functions or can i use them in one function.Please guide me.
1)Age in Years (Ex: 4)
2) Age in Years + months (ex: 3 Years 6 months)
My SSRS Custom Code:
Public Shared Dim Years as Integer
Public Shared Dim Months as Integer
Public Shared Dim Days as Integer
Public Shared Dim Age as Integer
Public Shared Function CalAge(ByVal D1 As Datetime,ByVal D2 As Datetime ) As Integer
  Years=Year(D1)-Year(D2)
  Months=Month(D1)-Month(D2)
  Days=Day(D1)-Day(D2)
       If Days < 0 then 
           Months=Months-1
         End if
       If Months < 0 then 
          Years=Years-1
         End if
       If Months < 0 then
          Months=Months+12
       End If
     Return Years 
If Months=1 then
    Age=Years+" Years " + Months + "Month"
else
  Age=Years+" Years " + Months + "Months" 
End If 
Return Age
  End Function

hi Guys,
I have finally changed my custom code to below :
Public Shared Dim Years as Integer
Public Shared Dim Months as Integer
Public Shared Dim Days as Integer
Public Shared Function CalAge(ByVal D1 As Datetime,ByVal D2 As Datetime ) As Integer
  Days=DatePart(DateInterval.Day,D1)-DatePart(DateInterval.Day,D2)
 Months=DatePart(DateInterval.Month,D1)-DatePart(DateInterval.Month,D2)
  Years=DatePart(DateInterval.Year,D1)-DatePart(DateInterval.Year,D2)
         If Days < 0 then 
           Months=Months-1
      End If
       If Months < 0 then 
          Years=Years-1
        End If
       If Months < 0 then
          Months=Months+12
       End If
     Return Years 
  End Function
Public Shared Function CalMon(ByVal D3 As Datetime,ByVal D4 As Datetime ) As Integer
   Days=DatePart(DateInterval.Day,D3)-DatePart(DateInterval.Day,D4)
   Months=DatePart(DateInterval.Month,D3)-DatePart(DateInterval.Month,D4)
  Years=DatePart(DateInterval.Year,D3)-DatePart(DateInterval.Year,D4)
     If Days < 0 then 
           Months=Months-1
      End If
       If Months < 0 then 
          Years=Years-1
        End If
       If Months < 0 then
          Months=Months+12
       End If
 Return Months 
  End Function
and using expression in SSRS fo display like this  :
=IIF((Code.CalMon(Parameters!AgeCalcDate.Value,Fields!StudentBirthDate.Value))=1,Code.CalAge(Parameters!AgeCalcDate.Value,Fields!StudentBirthDate.Value) & " Years " & Code.CalMon(Parameters!AgeCalcDate.Value,Fields!StudentBirthDate.Value)
& " Month ",
    Code.CalAge(Parameters!AgeCalcDate.Value,Fields!StudentBirthDate.Value) & " Years " & Code.CalMon(Parameters!AgeCalcDate.Value,Fields!StudentBirthDate.Value) & " Months ")
got the correct solution.

Similar Messages

  • Custom code in ssrs 2005

    hi sir
    i am fresher, 
    i need breif about custom code in ssrs,
    what is cutom code,
    why it is used,
    what is the perpose of this code...
    help me to learn.
    thank you.

    custom code is used mostly for implementing functionalities which cannot be done using standard features available in SSRS. Custom code should be written using .NET language. If you want to share same code across multiple reports you should make it into
    a dll and reference it from all the required reports.
    More details here
    https://msdn.microsoft.com/en-us/library/ms156028.aspx
    https://msdn.microsoft.com/en-us/library/ms159238.aspx
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Using custom code in SSRS PDF rendering

    Hi,
    I have a written some custom code ( a simple function to maintain a counter ) in SSRS Report properties.
    Everything works fine when I render the report in Report Viewer, but the custom code is not recognized when I render the report to PDF.
    What is wrong with my code?
    There is no error reported. The custom code is just getting skipped when I render to PDF.
    My custom code is as follows..
    Public Shared Dim iCounter AS Integer = 1
    Public Function IncrementCounter(SomeValue As Boolean) As Boolean
    iCounter = iCounter + 1
    Return SomeValue
    End Function
    Public Function GetCounter() As Integer
    Return iCounter
    End Function
    and my call to the custom code is..
    =code.GetCounter()

    Hi ha_emp,
    From your description, it seems that custom code work well when you preview the report. While it would be skipped when the report is exported to PDF. After testing the custom code in my environment,I find that the custom code will run again when exporting
    the report, so when we run the report on Report Server and export it to PDF, the custom code will be run twice, the value will be counted twice.
    Based on my research, I find that we can delete the “Shared” in the first row of the custom code to fix this issue. Then the custom code will works well on Report Server.
    If there are any misunderstanding, please elaborate the issue for further investigation.
    Thanks, 
    Katherine Xiong
    We
    are trying to better understand customer views on social support experience, so your participation in this
    interview project would be greatly appreciated if you have time.
    Thanks for helping make community forums a great place.

  • Performance issue due to localization code in SSRS 2008

    The reports I am working on consist lot of data and all the customers use it frequently.
    Report title and columns are localized by expressions .
    This takes long time for report rendering and exporting to csv. When I test without the localization code it doesn't take that long .
    Can someone help me to optimize the report. SSRS 2008 R2
    Archana

    Hi Archana,
    In Reporting Services, the total time to generate a reporting server report (RDL) can be divided into 3 elements:
    Total time = (TimeDataRetrieval) + (TimeProcessing) + (TimeRendering)
    TimeRendering means the number of milliseconds spent after the Rendering Object Model is exposed to the rendering extension. It includes the Time spent in on-demand expression evaluations (e.g. TextBox.Value, Style.*). So it is make sense that the report
    with localization code takes longer time.
    Besides, we can improve the report performance form other aspects. For example, we can add filter, sorting and aggregation in dataset query, because filter, sort, and aggregation is more efficient on the data source than during report processing. For more
    details about report performance, please refer to the following article:
    http://technet.microsoft.com/en-us/library/bb522806(v=sql.105).aspx
    If there are any other questions, please feel free to ask.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • Custom code in SSRS gives error when uploaded to report in CRM online

    Hi All;
    Below is my custom code 
    Function SumLookup(ByVal items As Object()) As Decimal
    If items Is Nothing Then
    Return Nothing
    End If
    Dim suma As Decimal = New Decimal()
    Dim ct as Integer = New Integer()
    suma = 0
    ct = 0
    For Each item As Object In items
    suma += Convert.ToDecimal(item)
    ct += 1
    Next
    If (ct = 0) Then return 0 else return suma
    End Function
    and this code is used in 
    =Code.SumLookup(LookupSet(Fields!new_mainprogrammeid.Value & "," &
    Fields!new_subprogrammeid.Value & "," &
    Fields!new_outputs.Value & "," &
    Fields!new_claimmonthid.Value,
    Fields!new_mainprogrammeid.Value & "," &
    Fields!new_subprogrammeid.Value & "," &
    Fields!new_outputs.Value & "," &
    Fields!new_claimmonthid.Value,
    Fields!new_fte.Value, "JobOutcome"))
    when this code is uploaded in CRM online report it gives an error 
    below is the error from the log file 
    Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: An error occurred while trying to add the report to Microsoft Dynamics CRM. Try adding the report again. If this problem persists, contact your system administrator.Detail:
    <OrganizationServiceFault xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/xrm/2011/Contracts">
    <ErrorCode>-2147188072</ErrorCode>
    <ErrorDetails xmlns:d2p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
    <Message>An error occurred while trying to add the report to Microsoft Dynamics CRM. Try adding the report again. If this problem persists, contact your system administrator.</Message>
    <Timestamp>2014-10-07T14:21:25.5823821Z</Timestamp>
    <InnerFault i:nil="true" />
    <TraceText i:nil="true" />
    </OrganizationServiceFault>
    but when i remove the custom code and upload the lookup as below i dont get any error
    =(LookupSet(Fields!new_mainprogrammeid.Value & "," &
    Fields!new_subprogrammeid.Value & "," &
    Fields!new_outputs.Value & "," &
    Fields!new_claimmonthid.Value,
    Fields!new_mainprogrammeid.Value & "," &
    Fields!new_subprogrammeid.Value & "," &
    Fields!new_outputs.Value & "," &
    Fields!new_claimmonthid.Value,
    Fields!new_fte.Value, "JobOutcome"))
    I need to calculate the sum of fte hence needed the custom code
    Any help on this much appreciated
    Thanks
    Pradnya07

    Hi Simran08,
    According to your description, you fail to add your report to CRM due to the custom code. Right?
    In this scenario, based on my knowledge, I find two issues in your custom code.
    You pass the array Items as argument to the function. This array is from the LookupSet() function. However, it returns an concatenated string with commas. When you convert it into decimal, it will throw error.
    In your For Each loop part, we should follow the format below:
    For Each element In group
    [statements]
    [Exit For]
    [statements]
    Next [element]
    It seems you miss Item after Next.
    If you still have any question, please feel free to ask.
    Best Regards,
    Simon Hou

  • SSRS VB Code error while deploying report -- There is an error on line 5 of custom code: [BC30201] Expression expected._

    Function MakeList(ByVal items As Object()) As String
        If items Is Nothing Then
          Return Nothing
    END if 
    Dim builder As System.Text.StringBuilder = 
          New System.Text.StringBuilder()
          builder.Append("<div>")
       For Each item As Object In items
          builder.Append("<div <ul>")
          builder.Append(item)
          builder.Append("</ul>")
       Next
       builder.Append("</div>")
       Return builder.ToString()
    End Function
    Function Length(ByVal items as Object()) as Integer
       If items is Nothing Then
          Return 0
       End If
       Return items.Length
    End Function

    Hi Wintersbay,
    According to your description, when you use the custom code in SSRS report, you got the error message.
    To solve the problem, please refer to the custom code below:
    Function MakeList(ByVal items As Object) As String
    If items Is Nothing Then
    Return Nothing
    END if
    Dim builder As System.Text.StringBuilder =
    New System.Text.StringBuilder()
    builder.Append("<div>")
    For Each item As Object In items
    builder.Append("<div <ul>")
    builder.Append(item)
    builder.Append("</ul>")
    Next
    builder.Append("</div>")
    Return builder.ToString()
    End Function
    Function Length(ByVal items as Object) as Integer
    If items is Nothing Then
    Return 0
    End If
    Return items.Length
    End Function
    If you have any more questions, please feel free to ask.
    Thanks,
    Wendy Fu
    Wendy Fu
    TechNet Community Support

  • How to dynamically set width of SSRS columns in custom code?

    How can I change the width of a table column based on a parameter value using custom code in SSRS?
    If the parameter value is "Excel", I'd like the width to be 2 inches. If the parameter value is "Standard", I'd like the width to be 1 inch.

    Hi mmx_pdx,
    Based on my research, we can only type static values for the width size in report. In Reporting Services, it not supported to set the size of width based on an expression currently. This is by design.
    Personally, I recommend you that submit this suggestion at
    https://connect.microsoft.com/SQLServer/. If the suggestion mentioned by customers for many times, the product team may consider to add the feature in the next SQL Server version. Your feedback is valuable for us to improve our products and increase the
    level of service provided.
    Thanks for your understanding.
    Regards,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • Hi iam new to implement custome code in sssrs when iam created connection in ssrs its throwing error please find the screen shot

    when iam previwing report this error is occured
    System.Data.SqlClient.SqlException: Login failed for user 'FPS\hariprasad.a'.
       at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
       at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
       at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
       at System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK)
       at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject)
       at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart)
       at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance)
       at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)
       at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection)
       at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnec

    hi pasted error .iam impleting custom code in ssrs like below
    Public Shared Function DeleteData(Byval empno AS Integer) As String
                    Dim strResult As String
                    Dim conn As New System.Data.SqlClient.SqlConnection
                    conn.ConnectionString = "Integrated Security=SSPI;Data Source=172.16.1.111\DATA_SERVICES;Initial Catalog=Recounsiled"
                    Dim sql As String
                    sql = "sp_empno"
                    Dim com As New System.Data.SqlClient.SqlCommand
                    com.CommandText = sql
                    com.CommandType = System.Data.CommandType.StoredProcedure
                    com.Parameters.Add("@empno", System.Data.SqlDbType.Int).Value =empno
                    com.Connection = conn
                    Try
                                    com.Connection.Open()
                                    com.ExecuteNonQuery()
            com.Connection.Close()
                                    strResult = "Successful"
                    Catch ex As Exception
                                    com.Connection.Close()
                                    strResult = ex.ToString()
                    End Try
                    return strResult
    End Function

  • How to control or manipulate a report parameter through SSRS Custom Code

    Hi,
    In reporting services 2005 or 2008, is it possible to control the parameters inside the custom code of a report?
    for example:
    Let's say I have a parameter that displays the following value:
    Red
    Green
    Blue
    In typical scenario I can select one of the values or I can select all of the values then click the View Report button in reporting services.
    I know that this approach is much easier to do if I have an external application like ASP.Net and from there I'll just add report viewer and control the parameters to be passed and then generate the report.
    In the report I added text box that will serve as a hyperlink to refresh report:
    In the Text Box Properties\Action tab. Is it possible to control the selection of values through a custom code(SSRS Custom Code) then the report will be automatically refreshed?
    thanks,
    Joefer

    Not sure about doing a multiple selection. But you can pop up an input box to get the input on the fly.
    Add the below custom code and expression for the above parameter
    Public function Getparamvalue() AS STRING
    Dim x as STRING
    x = InputBox("Enter Red / Blue / Green")
    Return(x)
    End function
    =Code.Getparamvalue()

  • Custom code dll as a data source for an SSRS report

    I'm trying to create a report which relies on using some custom code written in VB.net. I am using the custom code to access the Server Management Objects SMO API in MSSQL 2012. I am able to supply an MSSQL object name (a database table
    for example)and then return a list of dependant objects using the dependency walker class (stored procedures, triggers, UDF's, other tables etc.) which rely on the parent object if you will. I am able load the results into a dataset in the custom code. My
    question is how can I get that dataset to be consumed as a data source and appear in my report. I've read many articles on how to use scripts to supply values for various report property settings. I just haven't seen an example of using a dll
    to supply a dataset. I am assuming it is possible. Any thoughts or advice would be appreciated. Cheers     

    Hi mdmck,
    According to your description, you want to create an SSRS report with custom code as data source, right?
     To use custom code in Reporting Services, we need to add a reference to your custom assembly, create a new CodeGroup for your custom assembly, and then grant full trust permissions. For detail information, please refer to the following steps:
    Open the report that will reference the custom assembly.
    On the Report menu, click Report Properties.
    In the Report Properties dialog box, click the References tab.
    Under References, click the ellipsis (...) button that is next to the Assembly name column header.
    In the Add References dialog box, click Browse.
    Locate and then click the custom assembly. Click Open.
    In the Add References dialog box, click OK.
    In the Report Properties dialog box, click OK.
    If the custom assembly requires more permissions than the default Execution level permissions, we need to create a new CodeGroup for your custom assembly, and then grant full trust permissions.
    Here are relevant threads you can reference:
    https://social.technet.microsoft.com/Forums/en-US/c297bddc-c33c-4386-b284-41c1d87f37c6/custom-dlls-in-ssrs-reports?forum=sqlreportingservices
    https://social.technet.microsoft.com/Forums/en-US/27de3f46-5174-480d-b4d1-5e32772dae35/ssrs-2005-custom-code-shared-data-source-connection-string?forum=sqlreportingservices
    For more information about How to use custom assemblies or embedded code in Reporting Services, please refer to the following document:
    https://support.microsoft.com/kb/920769?
    If you have any more questions, please feel free to ask.
    Thanks,
    Wendy Fu
    If you have any feedback on our support, please click
    here.
    Wendy Fu
    TechNet Community Support

  • SSRS custom code for count in Report Footer

    Hi All,
    Please help me with the custom code used for below requirement
    Debtor Name     current    30+days   60+days    90+days
    aaa                       7000        0.00          0.00          10.00
    bbb                       5000        0.00         20.99         3.00
    ccc                        1000       0.00          0.00           0.00
    Expected result in report footer :                  
                                              0                1            
       2
    if  the value of  30+ , 60+ and 90+ columns  >=1 then i have to display the count in Report footer,for that i have tried using a custom code like below :
    Shared Dim OD As Integer=0
    Public Shared Function Test(ByVal OP As Decimal) As Integer
            If OP >= 1 Then
                OD = OD + 1
            Else
                OD = OD
            End If
            Return OD
       End Function
    and using below code to display
    Code.Test(Overdue)  
    but when i use this code in report footer is not displaying correct value.Please guide me where i am going wrong.
    Please let me know if you need any other details.
    Thanks in advance,
    Samhith.

    Hi Samhith,
    Per my understanding you what to count the rows which values >=1 and display them at the bottom of the table, you are trying to use the custom code to do this but failed, right?
    I have tested in my local environment and find the custom code is not correctly, and I have an alternative method which is more easy and can work in both table  and matrix.
    As Vaibhav Chaudhari also mentioned that we can use the CountDistinct function, but more correctly, we can use the count() function and the RunningValue() function, because CountDistict will not count the duplicated values if they >=1.
    Please find the expression as below:
    =Count(IIf(Fields!Yourfield.Value>=1 , Fields!Yourfield.Value, Nothing))
    OR:
    =RunningValue(IIf(Fields!Yourfield.Value>=1 , 1, Nothing),Sum,"DataSetName")
    If you still have any problem, please feel free to ask.
    Regards
    Vicky Liu

  • SSRS Custom Code Error There is an error on line 0 of custom code: [BC30205] End of statement expected.

    I am receiving this error with the following code, which counts the number of work days between two parameters and I don't see the problem. Please help.
    Public Function GetDateCount(ByVal StartDate AS DateTime, ByVal EndDate AS DateTime) AS Integer
    Dim TempVal AS Integer
    DimTotalDays AS Integer
    TotalDays = 0
    TempVal = DateDiff(DateInterval.Day, StartDate, EndDate) + 1
    for I as Integer = 1 to TempVal
    If(StartDate.DayOfWeek.ToString() <> "Sunday" AND StartDate.DayOfWeek.ToString() <> "Saturday") Then
    TotalDays = TotalDays +1
    End If
    StartDate = DateAdd(DateInterval.day, 1, StartDate)
    Next
    Return TotalDays
    End Function

    Hi CNet Vase,
    According to your description, you want to use custom code to count the number of work days between two parameters in the report, but when you run the report, an error occurs.
    I reproduced the issue in my environment, the error message: ‘DimTotalDays’ is not declared. The error is caused by there is no space between Dim and variable TotalDays, so the system regards it as a unit. To fix this issue, please type
    space behind the word Dim like below:
    Dim TotalDays AS Integer
    If there is any misunderstanding , please feel free to let me know.
    Best Regards, 
    Wendy Fu

  • SSRS Custom code

    Can we call custom code in parent report, which written in the subreport
    Thanks in advance

    Can we call custom code in parent report, which written in the subreport??
    Example :
    i have written code in subreport as follows 
    This can call it on parent report as "code.EmbeddedFunction()"
    Thanks in advance

  • SSRS Running Totals Custom Code

    I have a report in which I need to total a column with an expression and created simple code to have a running total.  When I run the report through report builder, the total only reflects the current page (it is 6 pages long) but if I export the report
    out to Excel, the total is correct.
    Below is the code:
    Public running_roy as Double = 0
    Public Function roy_tot(ByVal cust_type, ByVal roy, ByVal ret_value) as Double
    Dim temp_var as Double
    if cust_type = 0 then
    running_roy = running_roy + roy
    if ret_value = 0 then
    temp_var = roy
    else
    temp_var = running_roy
    end if
    ELSE
    temp_var = 0
    end if
    return temp_var
    End Function
    If I change the Public variable to "Public Shared" the totals change as I flip back and forth between the pages in report builder.
    Any suggestions?

    Hello alan2624,
    Thanks for your clarification.
    In the report, the custom code will be compiled as a class before it is used. Every time the page is loaded, the class on the page will be initialized. The un-shared (non-static) instance will be reset. Therefore, you will see the value is reset back to
    zero if the public variable is not announced as "Shared". If you announced it as shared, then the variable is on the class level. It will not be changed by instance initializing. In addition, any operations on the variable will be recorded. This is not the
    bug, but it is by design of the VB.net code.
    If you export the report to the Excel, I think it will only generate a single page, and the total value is only the last one. It should be correct. If it is used in the pages in browser, I suggest you need design your code carefully for VB.net design.
    If you have any questions about this issue, please let me know.
    Regards,
    Edward
    Edward Zhu
    TechNet Community Support

  • How to calculate difference and percentage in matrix report dynamic columns in SSRS 2008

    Hi Friends,
    I need to calculate Difference and Percentage In matrix report SSRS 2008
    1) Row grouping based On Product
    2) Column Grouping Week and Fiscal Year Current week  and Previous Year same Weeks 
    3)Data Invnetory(Value fileld)
    Example:
    If value1 and Value2 Available we need to calculate Percentage and Difference.Otherwise Not required NA I need to Show.
    For example If Particular week,Current year data is available,Previous year  week data is not available No
    need to cal Diff and Percentage we need to show Empty.
    Below Code is working for If two values is available.
    If any one of the fiscal year week data is not there it's taking some garbage values.
    I tries with If condition in GetPCT() and GetDiff() It's not working.
    Can some one please help me on this.
    I am using the custom code 
    Public Shared Value1 as String
    Public Shared Value2 as String
    Public Shared previous as string
    Public Shared previousweek as string
    Public Shared Function GetValue(Value as String,partner as String,Week as String) as String
    If partner =previous and Week =previousweek Then
    Value2=Value
    Else
    previous=partner
    previousweek=Week
    Value1=Value
    End If
    return Value
    End Function
    Public Shared Function GetDiff()
    return Value2-Value1
    End Function
    Public Shared Function GetPct()
    return (Value2-Value1)/Value1
    End Function
    How to handle this.
    Thank You, Manasa.V

    Hi veerapaneni,
    According to your description, if one of the fiscal year week doesn’t have data, the custom code returns false results.
    For your requirement, if NULL value exists in the database, we should replace it as zero then perform calculate. So within the code, we should judge whether the value is NULL. To achieve your goal, please refer to the steps below:
    1. Create a table like below.
    create table dif4
    ([Product Group] varchar(50),
    [Week] varchar(50),
    [Fiscalyearweek] varchar(50),
    value int
    insert into dif4 values
    ('Desktops','W01','FY14W01',0),
    ('Desktops','W01','FY15W01',45),
    ('Desktops','W02','FY14W02',null),
    ('Desktops','W02','FY15W02',30),
    ('Desktops','W03','FY14W03',12),
    ('Desktops','W03','FY15W03',50),
    ('Notebooks','W01','FY14W01',35),
    ('Notebooks','W01','FY15W01',56),
    ('Notebooks','W02','FY14W02',45),
    ('Notebooks','W02','FY15W02',87),
    ('Notebooks','W03','FY14W03',75),
    ('Notebooks','W03','FY15W03',105),
    ('Tablets','W01','FY14W01',34),
    ('Tablets','W01','FY15W01',46),
    ('Tablets','W02','FY14W02',49),
    ('Tablets','W02','FY15W02',96),
    ('Tablets','W03','FY14W03',42),
    ('Tablets','W03','FY15W03',113)
    2. Add the custom code in the Report Properties.
    Public Shared Value1 as Integer
    Public Shared Value2 as Integer
    Public Shared previous as string
    Public Shared previousweek as string
    Public Shared Function GetValue(Value as Integer,product as String,Week as String) as Integer
    If Value=Nothing Then
    Value=0
    End If
    If product =previous and Week =previousweek Then
    Value2=Value
    Else
    previous=product
    previousweek=Week
    Value1=Value
    End If
    return Value
    End Function
    Public Shared Function GetPct()
    If Value1=0 Then
    return 0
    Else
    return (Value2-Value1)/Value1
    End If
    End Function
    Public Shared Function GetDiff()
    return Value2-Value1
    End Function
    3. Design the matrix like below.
    4. Then get the expected results.<o:p></o:p>
    If you have any question, please feel free to ask.
    Best regards,
    Qiuyun Yu
    Qiuyun Yu
    TechNet Community Support

Maybe you are looking for

  • MBP sudden boot problem, gray screen then black zombie

    Hello all - I've had leopard installed on my MBP since Oct 27th and it's been running great, although I've noticed several times when I shut down, the machine really hadn't - I'd stick it in my briefcase only to find that the mac was on and the batte

  • Trying to Add a DFF Search criteria in Oracle Receivables (Customers HTML)

    Hi Everyone, I am trying to add a DFF search criteria within the Customer's HTML page. I was able to add the new message box, but am not sure how to tie the box to attribute 3 which is in the Receivables Party information Descriptive flex field. Orac

  • No audio with chrome

    i try to watch a video, and the actual video is fine, its the audio that doesnt work. I have tried many different things, i have done 3 system restores, i have researched all day, nothing has worked. (and yes the audio is not turned all the way down

  • Idoc in status 12 doesnt reach sap pi

    Hi folks, I have an Idoc2file scenario which is working fine in most cases but occasionnaly a message gets lost: SAP is sending the Idoc to port (goes to stat 03). There is no rfc error, SM58 and table ARFCSSTATE is empty. I run RBDMOIND and status g

  • Bulk changes to Common Resource Parameters

    Hi, I need to make changes to many disks and file server resources at once in my cluster. The settings I need to change are in the common properties for resources: http://msdn.microsoft.com/en-us/library/aa372230(v=vs.85).aspx RestartPeriod RestartTh