Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Manage Decimal Places with a Parameter
stephou85
Hello everyone,
I have encounter this problem several times.
Do you know an easy way to manage the "decimal places" with a report parameter ?
The problem is that with the Format Number Property, for the Decimal places attributes, we can use a javascript expression to set the value.
Thanks
Steph
Find more posts tagged with
Comments
CBR
Hi Steph,
you can use a script but only in event handler to change the number format.
What you can do is:
Change the number format using the number format property of the BIRT designer. Just provide values that make sense (i m assuming that you can say which currency your values are at least)
Add script to the beforeFactory event of your report like the following:
var nf = "###0.";
for(i=0; i<params["decimalPlaces"].value; i++) {
nf += "0";
}
myNumberFormat = nf+"{RoundingMode=HALF_UP}";
I m assuming that you have a report parameter called decimalPlaces which is a Integer and contain the number of decimal places in your report.
Now click on each data element for which you want to change the number format. Click on Script and choose the onCreate event using the drop down box on the top. Now simply add this script:
this.getStyle().numberFormat = myNumberFormat;
That's all.
stephou85
Hi Cbrell,<br />
<br />
I found an easier way without using the script in order to manage the decimals places with a parameter.<br />
I am using the Highlights property, and I apply a specific style (containing a format number style) on a condition using my Decimal Parameter.<br />
<br />
Any way, thanks you for the reply !<br />
<br />
<blockquote class='ipsBlockquote' data-author="'cbrell'" data-cid="84594" data-time="1319729075" data-date="27 October 2011 - 08:24 AM"><p>
Hi Steph,<br />
<br />
you can use a script but only in event handler to change the number format.<br />
<br />
What you can do is:<br />
<br />
Change the number format using the number format property of the BIRT designer. Just provide values that make sense (i m assuming that you can say which currency your values are at least)<br />
Add script to the beforeFactory event of your report like the following:<br />
<br />
var nf = "###0.";<br />
<br />
for(i=0; i<params["decimalPlaces"].value; i++) {<br />
nf += "0";<br />
}<br />
<br />
myNumberFormat = nf+"{RoundingMode=HALF_UP}";<br />
<br />
I m assuming that you have a report parameter called decimalPlaces which is a Integer and contain the number of decimal places in your report.<br />
<br />
Now click on each data element for which you want to change the number format. Click on Script and choose the onCreate event using the drop down box on the top. Now simply add this script:<br />
this.getStyle().numberFormat = myNumberFormat;<br />
<br />
That's all.<br /></p></blockquote>
CBR
That's easier indeed :-)
Thanks for sharing this solution.