How to get percentage for a field

2019-09-12 05:49发布

I would like to get percentage for a given field value. I am achieving this in excel by using formula. Is there a way to write down formula in SSRS?

I attached images here.

I need this

I need this

In excel i achieved by using formula, how to get this one in SSRS? I achieved in excel by this, How to get this one in SSRS

2条回答
smile是对你的礼貌
2楼-- · 2019-09-12 06:06

I used this custom code to get the percentage sum

Public Total_lookup_Sum As Integer = 0 
Public Function Lookup_Sum(ByVal value As Integer) As Integer
    Total_lookup_Sum = Total_lookup_Sum + value    
 Return Total_lookup_Sum 
End Function 

and i used this expression in tablix

=round(100*code.lookup_Sum(Reportitems!Textbox34.value),2)

source here

查看更多
你好瞎i
3楼-- · 2019-09-12 06:18

Yes, It's possible.

Use below expression

=Round(100 * (ReportItems!Number.Value / ReportItems!Number1.Value),2)

Here, ReportItems!Number.Value is the textbox name of Name Texbox and ReportItems!Number1.Value is the textbox name of Total Textbox.

See the below Image, It's working fine.

enter image description here

To Get Sum of percentage.

I would suggest to follow below things,

Go to Report properties, then Go To Code and then create the following function.

Public Sum_Perc As Integer = 0 
Public Function PercentageSum(ByVal value As Integer) As Integer
    Sum_Perc = Sum_Perc + value    
 Return Sum_Perc
End Function

Now, beside Name - Create Placeholder and set font to white as we don't required to show calculation on this cell. Do like below imageenter image description here.

Now, Set Expression like below image and text like this,

=Code.Sum_Perc

enter image description here

Hope, It will be helpful to you. Thanks

查看更多
登录 后发表回答