Easy question for iReports expression

0

For some reason, this expression is causing an error:

$F{media_stock_target_price} - $F{media_stock_target_cost} / $F{media_stock_target_price}

THANKS IN ADVANCE!!!

Error filling print... Error evaluating expression : 
    Source text : $F{media_stock_target_price}-$F{media_stock_target_cost}/$F{media_stock_target_price}
Setting up the file resolver... 
net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression : 
    Source text : $F{media_stock_target_price}-$F{media_stock_target_cost}/$F{media_stock_target_price} 
    at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:203) 
    at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:591) 
    at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:559) 
    at net.sf.jasperreports.engine.fill.JRFillElement.evaluateExpression(JRFillElement.java:966) 
    at net.sf.jasperreports.engine.fill.JRFillTextField.evaluateText(JRFillTextField.java:456) 
    at net.sf.jasperreports.engine.fill.JRFillTextField.evaluate(JRFillTextField.java:440) 
    at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:259) 
    at net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:455) 
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:2044) 
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillGroupHeader(JRVerticalFiller.java:639) 
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillGroupHeaders(JRVerticalFiller.java:561) 
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportContent(JRVerticalFiller.java:306) 
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFille

michaelwjoyner's picture
Joined: Dec 13 2012 - 9:45pm
Last seen: 11 months 2 weeks ago

1 Answer:

0

hard to as long you do not give more information... the error says that the expression cannot be evaluated. so, what can be wrong? 

possibly one of the fields is null? or the field "media_stock_target_price" is zero? (but in this case, as far as I know, you would get a "division by zero"  error)

check the datatypes and all possible contents of the fields! check the needed datatype of the element the expression is used in (TextField or sth like this?)

Cheers, Thomas

http://www.thomaszimmer.net

Thomas Zimmer's picture
Joined: Oct 2 2012 - 1:35am
Last seen: 5 days 12 hours ago

I did it from the SQL to avoid the problem

michaelwjoyner - 6 years 6 months ago

would be nice for other to describe shortly what the problem was exactly...

Thomas Zimmer - 6 years 6 months ago

I think we need to include Parentheses  $F{media_stock_target_price} - ($F{media_stock_target_cost} / $F{media_stock_target_price}) Please check it..

rsuddhala - 6 years 6 months ago
Feedback