locked
Calculate percentage RRS feed

  • Question

  • Dear All Experts,

    Please see the snap attached here.  I have desiged one matrix report.

    Now my problem is that i cant able to get Percentage automatically instead of that total is coming.

    Please see the yellow color highlighted column which i want to achieve.

    There are two row group and tow column group.

    Row group are 1) branch 2) Name
    Column group 1) Type 2) Amount

    In type Sales and Collection is coming
    and in Amount Group - Amt and target is coming.

    I hope you get my requirement.

    Please guide me how to do this.

    Regards,
    AKM


    • Edited by sqlakm Monday, May 27, 2013 8:44 AM
    Monday, May 27, 2013 7:12 AM

Answers

  • Hi Sqlakm,

    We can use custom code to do it. I have tested it on my environment, the steps below are for your reference.

    1. Copy the custom code below and paste it to your report. (Right-click report>Report Properties>Code)
      Dim Shared Num1 As Integer
      Dim shared Num2 As Integer
      Public Function GetAmount(Amount as Integer, Type as String) 
      If Type = "Amt" Then
         Num1=Amount
      Else
         Num2=Amount
      End If 
      Return Amount 
      End Function
      Public Function GetPec()
      Return Num1/Num2
      End function
    2. And then use the expression to the matrix.
      =Code.GetAmount(Fields!Amount.Value,Fields!Type.Value)
      =code.GetAmount(Sum(Fields!Amount.Value),Fields!Type.Value)
      =Code.GetPec()

    The report looks like below.

    If you have any questions, please feel free to ask.

    Regards,

      

    Charlie Liao
    TechNet Community Support

    • Marked as answer by Charlie Liao Monday, June 3, 2013 1:40 AM
    Tuesday, May 28, 2013 6:25 AM

All replies

  • In the matrix the settings to calculate as Percentage
    • Proposed as answer by SundaramR Monday, May 27, 2013 11:04 AM
    Monday, May 27, 2013 11:04 AM
  • There is not any setting of percentage.
    Monday, May 27, 2013 11:11 AM
  • Hi Sqlakm,

    We can use custom code to do it. I have tested it on my environment, the steps below are for your reference.

    1. Copy the custom code below and paste it to your report. (Right-click report>Report Properties>Code)
      Dim Shared Num1 As Integer
      Dim shared Num2 As Integer
      Public Function GetAmount(Amount as Integer, Type as String) 
      If Type = "Amt" Then
         Num1=Amount
      Else
         Num2=Amount
      End If 
      Return Amount 
      End Function
      Public Function GetPec()
      Return Num1/Num2
      End function
    2. And then use the expression to the matrix.
      =Code.GetAmount(Fields!Amount.Value,Fields!Type.Value)
      =code.GetAmount(Sum(Fields!Amount.Value),Fields!Type.Value)
      =Code.GetPec()

    The report looks like below.

    If you have any questions, please feel free to ask.

    Regards,

      

    Charlie Liao
    TechNet Community Support

    • Marked as answer by Charlie Liao Monday, June 3, 2013 1:40 AM
    Tuesday, May 28, 2013 6:25 AM