Report Viewer - Setting the decimal places for a textbox value

前端 未结 5 1503
情歌与酒
情歌与酒 2020-12-21 07:10

I\'m using Report Viewer Control (rdlc) to generate reports. One of my columns have the value

=AVG(Fields!Reading.Value, \"CellReading_Reading\")

相关标签:
5条回答
  • 2020-12-21 07:36
    FormatNumber(AVG(Fields!Reading.Value, "CellReading_Reading"),3)
    
    0 讨论(0)
  • 2020-12-21 07:36
    1. Right-click the textbox
    2. Click the number
    3. Select number from the category
    4. Set Decimal Places to 0
    0 讨论(0)
  • 2020-12-21 07:38

    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.

    0 讨论(0)
  • 2020-12-21 07:38

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

    0 讨论(0)
  • 2020-12-21 07:59

    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!

    0 讨论(0)
提交回复
热议问题