How can I prevent rounding off in rdlc report?

你说的曾经没有我的故事 提交于 2019-12-13 19:21:41

问题


In RDLC, One of the column output is 2.099. I want it as 2.09. I've already used Format and FormatNumber Function in RDLC expression. But the output is 2.10. But I need 2.09. How??

I have tried in these ways:

=FormatNumber (Sum(Switch((Fields!IsConsiderGPA.Value) = True , (Fields!Credit.Value) * (Fields!GPA.Value) )) / Sum(Switch(Fields!IsConsiderGPA.Value = True , (Fields!Credit.Value))),2)

=Format (Sum(Switch((Fields!IsConsiderGPA.Value) = True , (Fields!Credit.Value) * (Fields!GPA.Value) )) / Sum(Switch(Fields!IsConsiderGPA.Value = True , (Fields!Credit.Value))),"N")

=Format (Sum(Switch((Fields!IsConsiderGPA.Value) = True , (Fields!Credit.Value) * (Fields!GPA.Value) )) / Sum(Switch(Fields!IsConsiderGPA.Value = True , (Fields!Credit.Value))),"D")

And also changed the Number type in Text box properties. But failed.....


回答1:


Use Math.Trucate in your expression, ex:

=Math.Truncate(Sum(Switch((Fields!IsConsiderGPA.Value) = True , (Fields!Credit.Value) * (Fields!GPA.Value) )) / Sum(Switch(Fields!IsConsiderGPA.Value = True , (Fields!Credit.Value))))*100)/100

You can then format the number as you with in the "Number" vertical tab in the text box properties.




回答2:


create following custom function under "Report Properties", in code tab:

    Public Function WithoutRound(vl As String)

        Dim temp As String

        temp = FormatNumber(vl, 4)

        temp = Left(temp, Len(temp) - 2)

        Return temp

    End Function

and use it in textbox like

=Code.WithoutRound(Fields!RunningBalance.Value)



来源:https://stackoverflow.com/questions/17270363/how-can-i-prevent-rounding-off-in-rdlc-report

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