Rounding Numbers in Actuate

2.3k Views Asked by At

Using Actuate eReport Designer Professional 9 SErvice Pack 3 Fix 2

I am attempting to set a text control's ValueExp property to display a string consisting of a division result concatenated with some static text. I want the division result to display as an integer if there is no remainder. Otherwise, I want only 1 decimal place.

There will be conditional logic involved, but I will be able to handle that. What I am really looking for is, using the Expression Builder only, can I format numbers. For example, how would I get the expression, 5/3 & " text" to display 1.7 text? This guess,

 round(5/3, 1) & " text"

threw errors for "illegal variable use (round)" and "operator not found for these types"

From Dominique's answer, this effort:

BirtMath.round(5/3, 1)

resulted in an illegal variable use on BirtMath.

4

There are 4 best solutions below

0
Dan Bracuk On BEST ANSWER

What finally got the job done was:

Format(5/3, "##.#") & " text"
0
Dominique On

Try this:

BirtMath.round(5/3, 1) + " text"

(tested on BIRT Eclipse designer, this should be the same with actuate professional designer)

0
Peter Headland On

Dominique's answer refers to BIRT, which is a completely different technology/product.

If you want to display a numeric value with special formatting, a Text Control is not the best choice here. Instead, you should use a numeric control of the appropriate type (for example, a Double Control) and either override the GetText() method of that control to handle the display formatting or use Conditional Formatting. The reason this is a better solution is that data search and export will not work properly with a Text Control.

Note that you can use a format pattern like this: "#,##0 \T\e\x\t" instead of concatenating the string; this technique is needed when you are using Conditional Formatting.

Personally, I would prefer you to use Conditional Formatting, because I put a lot of effort into designing that feature of e.Reports, and I'd like to see more people using it. :) But overriding GetText() is probably easier in your specific situation, due to the need to do more complex string manipulation to eliminate the trailing decimals.

0
HeckDan On

I want to add that with BIRT, you can also format the text in a more 'graphic' way, without the need for SQL ... in case it is useful to someone ...

Select the Object - Properties - Format Number - You choose the Format

there is variety for each case and in addition to adding the custom format.

Of course, it is everyone's decision to how format the text, and it is always good to know how it is done in different ways!