I'm using Report Viewer Control (rdlc) to generate reports. One of my columns have the value
=AVG(Fields!Reading.Value, "CellReading_Reading")
I'm getting the value with 10 or more decimal places. But i want to round it off to 3 decimal places. What is the expression for doing this?
Thank you. NLV
cdonner's answer was great and I incorporated it myself. If you have a slightly more complicated case as I did and you want to concatenate more than 1 field from more than 1 dataset you can do it like this...
=FormatNumber(Sum(Fields!Actual_Measurement.Value, "Measured_Result"), 1) & " (" & FormatNumber(First(Fields!Allowed_Min.Value, "Measured_Result_Details"), 1) & " - " & FormatNumber(First(Fields!Allowed_Max.Value, "Measured_Result_Details"), 1) & ")"
An example of what is displayed here would be ...
15.3 (12 - 16)
... If Actual_Measurement = 15.3, Allowed_Min = 12 and Allowed_Max = 16
In this case 1 entry in the "Measured_Result_Details" table relates to 1 or many entries in the "Measured_Result" table. Right clicking on the box and selecting "Expression", then looking in "Datasets" my two "Items" are "Measured_Result_Details" and "Measured_Result". This may be useful to anyone who has more than 1 dataset with fields from each dataset to be displayed in 1 Text Box!
The simplest approach should be to just enter
N3
in theformat
property of the textbox.N
stands for the number andC
stands for the currencyExamples:
N0
format123456.12
as123,456
C2
format1234.562
as$1,234.56
and so on ...
Decimal Places
to 0If you want without rounding off use
Math.Truncate
:Reference this and this post .
Hope helps.