bhpanchal Posted July 14, 2015 Posted July 14, 2015 Hello,We are creating one report and we need to apply multiple formulas in it. Below condition is not working into the variable.Create one variable and put below condition in it.(($F{bill_IIDate} == $F{bill_payDate}) ? ($F{bill_payAmount}) : (($F{InvoiceTotal} > $F{bill_payAmount}) ? ($F{bill_payAmount}) : ($F{InvoiceTotal}))) Data: bill_IIDatebill_payDateInvoiceTotalbill_payAmount4/2/20154/2/2015-800Output : -80Correct result : 0Can anybody help me please?Bhavin Panchal
Tom C Posted July 14, 2015 Posted July 14, 2015 Please make sure to use the correct Java class method to compare your data. A simplified version of your ternary operators is as the following:$F{bill_iidate}.equals($F{bill_paydate})||$F{invoicetotal}.intValue()>$F{bill_payamount}.intValue())?$F{bill_payamount}:$F{invoicetotal} You can review the following sample report design template to see how it works - you can test it in Studio using any PostgreSQL data source.<?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 6.1.0.final using JasperReports Library version 6.1.0 --><!-- 2015-07-14T13:53:27 --><jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="demo for bhpan" pageWidth="612" pageHeight="792" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="096c7815-e4bc-4c28-bd8c-20dce298feb5"> <property name="com.jaspersoft.studio.data.defaultdataadapter" value="JRSrepo"/> <queryString> <![CDATA[select date '2015-04-02' as bill_IIDate, date '2015-04-01' as bill_payDate, -80 as InvoiceTotal, 0 as bill_payAmountunion allselect date '2015-04-02' as bill_IIDate, date '2015-04-02' as bill_payDate, -80 as InvoiceTotal, 0 as bill_payAmountunion allselect date '2015-04-02' as bill_IIDate, date '2015-04-03' as bill_payDate, -80 as InvoiceTotal, 0 as bill_payAmount]]> </queryString> <field name="bill_iidate" class="java.sql.Date"/> <field name="bill_paydate" class="java.sql.Date"/> <field name="invoicetotal" class="java.lang.Integer"/> <field name="bill_payamount" class="java.lang.Integer"/> <variable name="Variable_1" class="java.lang.Integer"> <variableExpression><![CDATA[($F{bill_iidate}.equals($F{bill_paydate})||$F{invoicetotal}.intValue()>$F{bill_payamount}.intValue())?$F{bill_payamount}:$F{invoicetotal}]]></variableExpression> </variable> <background> <band splitType="Stretch"/> </background> <title> <band splitType="Stretch"> <property name="com.jaspersoft.studio.unit.height" value="pixel"/> </band> </title> <pageHeader> <band splitType="Stretch"> <property name="com.jaspersoft.studio.unit.height" value="pixel"/> </band> </pageHeader> <columnHeader> <band height="30" splitType="Stretch"> <property name="com.jaspersoft.studio.unit.height" value="pixel"/> <staticText> <reportElement x="0" y="0" width="100" height="30" uuid="099f3458-7a28-420e-80b8-7a85588f3fec"/> <text><![CDATA[bill_iidate]]></text> </staticText> <staticText> <reportElement x="100" y="0" width="100" height="30" uuid="f39aacf9-579c-4342-ac1a-9bbcfa516441"/> <text><![CDATA[bill_paydate]]></text> </staticText> <staticText> <reportElement x="200" y="0" width="100" height="30" uuid="987777e6-16cf-4b37-bb43-b60959a1afd2"/> <text><![CDATA[invoicetotal]]></text> </staticText> <staticText> <reportElement x="300" y="0" width="100" height="30" uuid="93c96dce-6916-45bf-9451-35d9c5162702"/> <text><![CDATA[bill_payamount]]></text> </staticText> <staticText> <reportElement x="400" y="0" width="100" height="30" uuid="9a081ae9-d59b-453d-ac9d-0bedefa86c75"/> <text><![CDATA[RESULT]]></text> </staticText> </band> </columnHeader> <detail> <band height="30" splitType="Stretch"> <property name="com.jaspersoft.studio.unit.height" value="pixel"/> <textField pattern="M/d/yyyy"> <reportElement x="0" y="0" width="100" height="30" uuid="288a3035-e5de-4a3f-9032-b2f6a535462c"/> <textFieldExpression><![CDATA[$F{bill_iidate}]]></textFieldExpression> </textField> <textField pattern="M/d/yyyy"> <reportElement x="100" y="0" width="100" height="30" uuid="6f5a3738-9948-4b6a-b0bd-7a3ad2687edc"/> <textFieldExpression><![CDATA[$F{bill_paydate}]]></textFieldExpression> </textField> <textField> <reportElement x="200" y="0" width="100" height="30" uuid="769d6855-c6b7-4039-85e2-e5f7d82218b9"/> <textFieldExpression><![CDATA[$F{invoicetotal}]]></textFieldExpression> </textField> <textField> <reportElement x="300" y="0" width="100" height="30" uuid="558043be-8199-455b-bea2-5256e1e6dd5a"/> <textFieldExpression><![CDATA[$F{bill_payamount}]]></textFieldExpression> </textField> <textField> <reportElement x="400" y="0" width="100" height="30" uuid="e235fda1-1033-4549-9728-031c83026697"/> <textElement> <font isBold="true"/> </textElement> <textFieldExpression><![CDATA[$V{Variable_1}]]></textFieldExpression> </textField> </band> </detail> <columnFooter> <band splitType="Stretch"> <property name="com.jaspersoft.studio.unit.height" value="pixel"/> </band> </columnFooter> <pageFooter> <band splitType="Stretch"> <property name="com.jaspersoft.studio.unit.height" value="pixel"/> </band> </pageFooter> <summary> <band splitType="Stretch"> <property name="com.jaspersoft.studio.unit.height" value="pixel"/> </band> </summary></jasperReport>The report output is:
bhpanchal Posted July 15, 2015 Author Posted July 15, 2015 Thanks a lot. Issue has been resolved now.Bhavin Panchal
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now