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.
1 Answer:
Posted on June 14, 2018 at 6:26am
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>