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

Upvotes: 1

Views: 2614

Answers (2)

user1776874
user1776874

Reputation: 16

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)

Upvotes: 0

Carlos Ferreira
Carlos Ferreira

Reputation: 432

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.

Upvotes: 2

Related Questions