String to Integer

0

I am trying to take the average of account premiums, and the account premium is reading as a string value rather than integer. I have tried to convert is by using:

Average($F{"AccountExt_TotalAccountPremium" == null?0:Inteer.valueOf($F{"AccountExt_TotalAccountPremium"}, 'Current')

but this is not working, "Incorrect expression". Help! I feel like this may be a problem for most of the fields I need to use.

arielplaski's picture
Joined: Jun 13 2018 - 11:08am
Last seen: 1 year 5 months ago

1 Answer:

0

Hi

Not sure if I understand fully what you are trying to do but..

Is there a reason why you cannot create the AccountPremium as an integer at the
start eg:  ?

<variable name="ACCOUNT_PREMIUM" class="java.lang.Integer"/>


or as an input field

<field name="ACCOUNT_PREMIUM" class="java.lang.Integer"/>

Personally I use class="java.math.BigDecimal" for currency
eg:

<field name="ACCOUNT_PREMIUM" class="java.math.BigDecimal"/>

Then the average would be calculated something like this.

<variable name="AVE_ACCOUNT_PREMIUM" class="java.lang.Integer" incrementType="Report" calculation="Average">
    <variableExpression><![CDATA[$F{ACCOUNT_PREMIUM}]]></variableExpression>
    <initialValueExpression><![CDATA[$F{ACCOUNT_PREMIUM}]]></initialValueExpression>
</variable>

peter.w's picture
303
Joined: Oct 12 2012 - 6:57am
Last seen: 2 months 4 days ago
Feedback