4

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

NLV
  • 21,141
  • 40
  • 118
  • 183

5 Answers5

15
FormatNumber(AVG(Fields!Reading.Value, "CellReading_Reading"),3)
cdonner
  • 37,019
  • 22
  • 105
  • 153
2
  1. Right-click the textbox
  2. Click the number
  3. Select number from the category
  4. Set Decimal Places to 0
Arman H
  • 5,488
  • 10
  • 51
  • 76
1

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!

Ewan
  • 541
  • 8
  • 23
0

If you want without rounding off use Math.Truncate:

=Math.Truncate(1000*(AVG(Fields!Reading.Value, "CellReading_Reading")))/1000

Reference this and this post .

Hope helps.

Community
  • 1
  • 1
Shaiju T
  • 6,201
  • 20
  • 104
  • 196
0

The simplest approach should be to just enter N3 in the format property of the textbox.

N stands for the number and C stands for the currency

Examples:

N0 format 123456.12 as 123,456

C2 format 1234.562 as $1,234.56

and so on ...

vaheeds
  • 2,594
  • 4
  • 26
  • 36