How to get percentage for a field

邮差的信 提交于 2019-12-13 05:55:29

问题


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

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


回答1:


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.

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 image.

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

=Code.Sum_Perc

Hope, It will be helpful to you. Thanks




回答2:


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



来源:https://stackoverflow.com/questions/37471597/how-to-get-percentage-for-a-field

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!