2016-05-10 4 views
0

私はJasperSoftスタジオ6.2ジャスパーレポートクロスタブの状態での対策

で作業しています。ここには、1つのクロスタブ(実際の問​​題からのモックアップ)を使った簡単なレポートがあります。私は小節内に条件を追加して、通貨がgbpのときvalに3を掛ける必要があります。しかし、これは起こっていないようで、通貨に関係なく小節が表示されます。

このレポートは、現在表示されて何されています

enter image description here

をC1とr2のセルが3でなければなりませんので、C2のセルとr2

メジャーの式があります

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

セットクエリ

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 

レポート:

<?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

この$ F {currency} .equals( "gbp")を試していただけますか? $ F {val} * 3:$ F {val}? –

+0

@FahadAnjumあなたは正しいです!答えに入れてください。 – thotwielder

答えて

0

$ F {通貨} .equals( "GBP")? $ F {val} * 3:$ F {val}

==と.equalsの違いを検索できます。

関連する問題