How to Format Numeric Data with Units in Bold Reports Designer
Published:
Updated:
Presenting numeric data with clear formatting and meaningful units (such as “kg” for weight) improves report readability for your end-users. This article explains how to use expressions in Bold Reports Designer to format numbers, handle null values, and append suffixes.
Learn how to format numeric values and append unit suffixes like “kg” or “lbs” using expressions in Bold Reports Designer. This approach ensures your data is professional, clear, and handles empty fields gracefully.
Step-by-Step Instructions
1. Open the Expression Editor
- Launch Bold Reports Designer and open the report RDL (Report Definition Language) file.
- Select the Textbox or cell where the formatted value should appear.
- Click the Pencil icon to open the text editor, or locate the Value property in the Properties pane.
- Right-click the field and select Expression from the context menu to open the Expression Editor dialog.
2. Enter the Formatting Expression
To ensure the report looks professional, you must handle potential null values and define the decimal precision.
- In the Expression Editor, enter the following code:
=IIF(IsNothing(Fields!Weight.Value), "", Format(Fields!Weight.Value, "N2") & " kg")
Understanding the code:
IsNothing(Fields!Weight.Value): Checks whether the field contains a null value.IIF(..., "", ...): Returns an empty string when the value is null, preventing errors or unwanted output.Format(..., "N2"): Formats the number with two decimal places and includes a thousands separator (e.g., 1,250.50).& " kg": The ampersand operator appends the string " kg" to the end of the formatted number.
3. Preview and Verify the Results
- Click OK to save the expression.
- Click Preview from the top toolbar to render the report.
- Verify the following:
- Numbers display with exactly two decimal places.
- The “kg” suffix appears immediately after the number.
- Fields with no data remain blank rather than showing “kg” alone.