2016-05-10 2 views
0

ich arbeite in Jaspersoft Studio 6.2Jaspis Bericht Quer Registerkarte Zustand in Maßnahmen

Hier ist ein einfacher Bericht mit einer Querlasche (ein Mock-up aus der realen Ausgabe). Ich möchte eine Bedingung in der Maßnahme hinzufügen, so dass, wenn die Währung gbp ist, das val mit 3 multipliziert werden sollte. Aber das scheint nicht zu geschehen, die Maßzahl zeigt nur das Val unabhängig von der Währung.

Dies ist, was der Bericht zeigt nun:

bei c1 und r2

enter image description here

Die Zelle 3 sollte sein, so dass die Zelle an der c2 und r2

Der Ausdruck für die Maßnahme ist

$F{currency} == "gbp"? $F{val}*3 : $F{val} 

Die Datasetabfrage

select 'c1' as cg, 'r1' as rg, 1 as val, 'aud' as currency 
    union all select 'c1' as cg, 'r2' as rg, 1 as val, 'gbp' as currency 
    union all select 'c2' as cg, 'r1' as rg, 1 as val, 'aud' as currency 
    union all select 'c2' as cg, 'r2' as rg, 1 as val, 'gbp' as currency 

Der Bericht:

<?xml version="1.0" encoding="UTF-8"?> 
    <!-- Created with Jaspersoft Studio version 6.2.0.final using JasperReports Library version 6.2.0 --> 
    <!-- 2016-05-10T10:19:28 --> 
    <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="test6" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="472d0a21-f9e0-4b4c-8830-53ce76baca95"> 
     <property name="com.jaspersoft.studio.data.sql.tables" value=""/> 
     <property name="com.jaspersoft.studio.data.defaultdataadapter" value="datamart"/> 
     <style name="Crosstab_CH" mode="Opaque" backcolor="#F0F8FF"> 
      <box> 
       <pen lineWidth="0.5" lineColor="#000000"/> 
       <topPen lineWidth="0.5" lineColor="#000000"/> 
       <leftPen lineWidth="0.5" lineColor="#000000"/> 
       <bottomPen lineWidth="0.5" lineColor="#000000"/> 
       <rightPen lineWidth="0.5" lineColor="#000000"/> 
      </box> 
     </style> 
     <style name="Crosstab_CG" mode="Opaque" backcolor="#BFE1FF"> 
      <box> 
       <pen lineWidth="0.5" lineColor="#000000"/> 
       <topPen lineWidth="0.5" lineColor="#000000"/> 
       <leftPen lineWidth="0.5" lineColor="#000000"/> 
       <bottomPen lineWidth="0.5" lineColor="#000000"/> 
       <rightPen lineWidth="0.5" lineColor="#000000"/> 
      </box> 
     </style> 
     <style name="Crosstab_CT" mode="Opaque" backcolor="#005FB3"> 
      <box> 
       <pen lineWidth="0.5" lineColor="#000000"/> 
       <topPen lineWidth="0.5" lineColor="#000000"/> 
       <leftPen lineWidth="0.5" lineColor="#000000"/> 
       <bottomPen lineWidth="0.5" lineColor="#000000"/> 
       <rightPen lineWidth="0.5" lineColor="#000000"/> 
      </box> 
     </style> 
     <style name="Crosstab_CD" mode="Opaque" backcolor="#FFFFFF"> 
      <box> 
       <pen lineWidth="0.5" lineColor="#000000"/> 
       <topPen lineWidth="0.5" lineColor="#000000"/> 
       <leftPen lineWidth="0.5" lineColor="#000000"/> 
       <bottomPen lineWidth="0.5" lineColor="#000000"/> 
       <rightPen lineWidth="0.5" lineColor="#000000"/> 
      </box> 
     </style> 
     <queryString> 
      <![CDATA[select 'c1' as cg, 'r1' as rg, 1 as val, 'aud' as currency 
    union all select 'c1' as cg, 'r2' as rg, 1 as val, 'gbp' as currency 
    union all select 'c2' as cg, 'r1' as rg, 1 as val, 'aud' as currency 
    union all select 'c2' as cg, 'r2' as rg, 1 as val, 'gbp' as currency]]> 
     </queryString> 
     <field name="cg" class="java.lang.String"/> 
     <field name="rg" class="java.lang.String"/> 
     <field name="val" class="java.lang.Integer"/> 
     <field name="currency" class="java.lang.String"/> 
     <background> 
      <band splitType="Stretch"/> 
     </background> 
     <summary> 
      <band height="220" splitType="Stretch"> 
       <crosstab> 
        <reportElement x="0" y="20" width="555" height="200" uuid="db69b441-d09f-49f7-b290-7eec7275eb1b"> 
         <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/> 
        </reportElement> 
        <rowGroup name="rg1" width="60" totalPosition="End"> 
         <bucket class="java.lang.String"> 
          <bucketExpression><![CDATA[$F{rg}]]></bucketExpression> 
         </bucket> 
         <crosstabRowHeader> 
          <cellContents mode="Opaque" style="Crosstab_CH"> 
           <textField> 
            <reportElement x="0" y="0" width="60" height="20" uuid="6f2b3dc8-ae54-4dd9-b74d-8f708dfe0e52"/> 
            <textFieldExpression><![CDATA[$V{rg1}]]></textFieldExpression> 
           </textField> 
          </cellContents> 
         </crosstabRowHeader> 
         <crosstabTotalRowHeader> 
          <cellContents mode="Opaque" style="Crosstab_CT"> 
           <staticText> 
            <reportElement x="0" y="0" width="60" height="20" forecolor="#FFFFFF" uuid="23c06ac5-0336-4dec-a4f1-6a9e48d9b470"/> 
            <text><![CDATA[Total rg1]]></text> 
           </staticText> 
          </cellContents> 
         </crosstabTotalRowHeader> 
        </rowGroup> 
        <columnGroup name="cg1" height="20" totalPosition="End"> 
         <bucket class="java.lang.String"> 
          <bucketExpression><![CDATA[$F{cg}]]></bucketExpression> 
         </bucket> 
         <crosstabColumnHeader> 
          <cellContents mode="Opaque" style="Crosstab_CH"> 
           <textField> 
            <reportElement x="0" y="0" width="60" height="20" uuid="9872abc3-cac8-4b20-8dac-8f3d294d6c0d"/> 
            <textFieldExpression><![CDATA[$V{cg1}]]></textFieldExpression> 
           </textField> 
          </cellContents> 
         </crosstabColumnHeader> 
         <crosstabTotalColumnHeader> 
          <cellContents mode="Opaque" style="Crosstab_CT"> 
           <staticText> 
            <reportElement x="0" y="0" width="60" height="20" forecolor="#FFFFFF" uuid="fc087f0f-321d-46eb-b4ac-44eea96ff044"/> 
            <text><![CDATA[Total cg1]]></text> 
           </staticText> 
          </cellContents> 
         </crosstabTotalColumnHeader> 
        </columnGroup> 
        <measure name="val_MEASURE1" class="java.lang.Integer" calculation="Sum"> 
         <measureExpression><![CDATA[$F{currency} == "gbp"? $F{val}*3 : $F{val}]]></measureExpression> 
        </measure> 
        <crosstabCell width="60" height="20"> 
         <cellContents mode="Opaque" style="Crosstab_CD"> 
          <textField> 
           <reportElement x="0" y="0" width="60" height="20" uuid="827bc665-96dc-4adc-9a75-e4549d146d79"/> 
           <textFieldExpression><![CDATA[$V{val_MEASURE1}]]></textFieldExpression> 
          </textField> 
         </cellContents> 
        </crosstabCell> 
        <crosstabCell width="60" height="20" columnTotalGroup="cg1"> 
         <cellContents mode="Opaque" style="Crosstab_CT"> 
          <textField> 
           <reportElement x="0" y="0" width="60" height="20" forecolor="#FFFFFF" uuid="4d85b6d3-b844-4072-aa29-d33559efd678"/> 
           <textFieldExpression><![CDATA[$V{val_MEASURE1}]]></textFieldExpression> 
          </textField> 
         </cellContents> 
        </crosstabCell> 
        <crosstabCell width="60" height="20" rowTotalGroup="rg1"> 
         <cellContents mode="Opaque" style="Crosstab_CT"> 
          <textField> 
           <reportElement x="0" y="0" width="60" height="20" forecolor="#FFFFFF" uuid="f83e2d2f-ad1f-47e7-ac36-567f47862219"/> 
           <textFieldExpression><![CDATA[$V{val_MEASURE1}]]></textFieldExpression> 
          </textField> 
         </cellContents> 
        </crosstabCell> 
        <crosstabCell width="60" height="20" rowTotalGroup="rg1" columnTotalGroup="cg1"> 
         <cellContents mode="Opaque" style="Crosstab_CT"> 
          <textField> 
           <reportElement x="0" y="0" width="60" height="20" forecolor="#FFFFFF" uuid="668927e0-801e-415d-ab82-36040ad4f830"/> 
           <textFieldExpression><![CDATA[$V{val_MEASURE1}]]></textFieldExpression> 
          </textField> 
         </cellContents> 
        </crosstabCell> 
       </crosstab> 
      </band> 
     </summary> 
    </jasperReport> 
+0

Können Sie bitte versuchen, diese $ F {Währung} .equals ("gbp")? $ F {val} * 3: $ F {val}? –

+0

@FahadAnjum Sie haben Recht! Kannst du das bitte in die Antwort schreiben? – thotwielder

Antwort

0

$ F {currency} .equals ("gbp")? $ F {val} * 3: $ F {val}

Sie können den Unterschied zwischen == und .equals suchen.

Verwandte Themen