Search code examples
reportrdlc

How can I prevent rounding off in rdlc report?


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


Solution

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