2016-11-07 2 views
-1

J'ai un tableau croisé fait de l'ensemble de données comme suitCrosstab application de fonctions calculées par défaut

enter image description here

Je me attends pas de fonction de calcul sur les colonnes de mesure. Mais, le rapport quand il s'exécute prend toujours le plus haut par défaut et le résultat ressemble à ci-dessous. Comment puis-je obtenir le rapport juste pour donner les données pivotées et ne pas effectuer de calcul sur les mesures?

enter image description here

J'espère que les données de regarder comme indiqué dans l'image ci-dessous

http://i66.tinypic.com/adnac7.jpg

S'il vous plaît trouverez ci-dessous la jrxml liée

<?xml version="1.0" encoding="UTF-8"?> 
<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="crosstabmeasure" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="e47b3f7d-1e00-4702-a900-be50a229f085"> 
    <import value="org.apache.commons.lang3.time.*"/> 
    <import value="java.util.Date"/> 
    <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> 
    <subDataset name="set1" uuid="0271cb46-f184-47b2-8ab3-e6ee96ea33ef"> 
     <parameter name="Locale" class="java.lang.String"/> 
     <parameter name="UtcOffSet" class="java.lang.Integer"/> 
     <queryString> 
      <![CDATA[select @curRank := @curRank + 1 AS rank, inter.* 
from internatioinlization inter, (SELECT @curRank := 0) r 
where 1 = case when 1 = 1 and $P{Locale} is not null and $P{UtcOffSet} is not null then 1 else 0 end]]> 
     </queryString> 
     <field name="rank" class="java.lang.Double"/> 
     <field name="col1" class="java.lang.String"/> 
     <field name="col2" class="java.lang.Integer"/> 
     <field name="col3" class="java.sql.Timestamp"/> 
     <field name="col4" class="java.lang.String"/> 
    </subDataset> 
    <parameter name="Locale" class="java.lang.String"/> 
    <parameter name="UtcOffSet" class="java.lang.Integer"/> 
    <queryString> 
     <![CDATA[select @curRank := @curRank + 1 AS rank, inter.* 
from internatioinlization inter, (SELECT @curRank := 0) r 
where 1 = case when 1 = 1 and $P{Locale} is not null and $P{UtcOffSet} is not null then 1 else 0 end]]> 
    </queryString> 
    <field name="rank" class="java.lang.Double"/> 
    <field name="col1" class="java.lang.String"/> 
    <field name="col2" class="java.lang.Integer"/> 
    <field name="col3" class="java.sql.Timestamp"/> 
    <field name="col4" class="java.lang.String"/> 
    <summary> 
     <band height="211" splitType="Stretch"> 
      <crosstab> 
       <reportElement x="0" y="0" width="555" height="211" uuid="6c5ccb8a-50fc-4158-b2ba-88d864aa1e43"> 
       </reportElement> 
       <crosstabParameter name="Locale"> 
        <parameterValueExpression><![CDATA[$P{REPORT_PARAMETERS_MAP}.get("Locale")]]></parameterValueExpression> 
       </crosstabParameter> 
       <crosstabParameter name="UtcOffSet" class="java.lang.Integer"> 
        <parameterValueExpression><![CDATA[$P{REPORT_PARAMETERS_MAP}.get("UtcOffSet")]]></parameterValueExpression> 
       </crosstabParameter> 
       <crosstabDataset> 
        <dataset> 
         <datasetRun subDataset="set1" uuid="d255c9b9-fbb2-420a-8ef5-3236098654f1"> 
          <datasetParameter name="Locale"> 
           <datasetParameterExpression><![CDATA[$P{Locale}]]></datasetParameterExpression> 
          </datasetParameter> 
          <datasetParameter name="UtcOffSet"> 
           <datasetParameterExpression><![CDATA[$P{UtcOffSet}]]></datasetParameterExpression> 
          </datasetParameter> 
          <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression> 
         </datasetRun> 
        </dataset> 
       </crosstabDataset> 
       <rowGroup name="col11" width="60"> 
        <bucket class="java.lang.String"> 
         <bucketExpression><![CDATA[$F{col1}]]></bucketExpression> 
        </bucket> 
        <crosstabRowHeader> 
         <cellContents mode="Opaque" style="Crosstab_CH"> 
          <textField> 
           <reportElement x="0" y="0" width="60" height="20" uuid="86c09a7f-46b5-4d2f-ba87-715f99d832a8"/> 
           <textElement textAlignment="Center" verticalAlignment="Middle"/> 
           <textFieldExpression><![CDATA[$V{col11}]]></textFieldExpression> 
          </textField> 
         </cellContents> 
        </crosstabRowHeader> 
        <crosstabTotalRowHeader> 
         <cellContents> 
          <staticText> 
           <reportElement x="0" y="0" width="-2147483648" height="-2147483648" uuid="94fca0ea-1572-4d42-85d9-b06f92c73b6e"/> 
           <text><![CDATA[Total col11]]></text> 
          </staticText> 
         </cellContents> 
        </crosstabTotalRowHeader> 
       </rowGroup> 
       <columnGroup name="col41" height="20"> 
        <bucket class="java.lang.String"> 
         <bucketExpression><![CDATA[$F{col4}]]></bucketExpression> 
        </bucket> 
        <crosstabColumnHeader> 
         <cellContents mode="Opaque" style="Crosstab_CH"> 
          <textField> 
           <reportElement x="0" y="0" width="120" height="20" uuid="137ef406-6a2e-4629-9d38-4858c4a5ae2c"/> 
           <textElement textAlignment="Center" verticalAlignment="Middle"/> 
           <textFieldExpression><![CDATA[$V{col41}]]></textFieldExpression> 
          </textField> 
         </cellContents> 
        </crosstabColumnHeader> 
        <crosstabTotalColumnHeader> 
         <cellContents> 
          <staticText> 
           <reportElement x="0" y="0" width="-2147483648" height="-2147483648" uuid="5c71211d-f1db-4911-8923-2bdb208ddb99"/> 
           <text><![CDATA[Total col41]]></text> 
          </staticText> 
         </cellContents> 
        </crosstabTotalColumnHeader> 
       </columnGroup> 
       <measure name="col2_MEASURE1" class="java.lang.Integer"> 
        <measureExpression><![CDATA[$F{col2}]]></measureExpression> 
       </measure> 
       <measure name="col3_MEASURE1" class="java.sql.Timestamp"> 
        <measureExpression><![CDATA[$F{col3}]]></measureExpression> 
       </measure> 
       <crosstabCell width="120" height="20"> 
        <cellContents mode="Opaque" style="Crosstab_CD"> 
         <textField> 
          <reportElement x="0" y="0" width="60" height="20" uuid="861d0d3a-d774-4b0c-ae7d-ace315bf305c"/> 
          <box> 
           <topPen lineWidth="0.5"/> 
           <leftPen lineWidth="0.5"/> 
           <bottomPen lineWidth="0.5"/> 
           <rightPen lineWidth="0.5"/> 
          </box> 
          <textElement textAlignment="Center" verticalAlignment="Middle"/> 
          <textFieldExpression><![CDATA[$V{col2_MEASURE1}]]></textFieldExpression> 
         </textField> 
         <textField> 
          <reportElement x="60" y="0" width="60" height="20" uuid="163ed502-e753-444a-942d-832d84da0a5f"/> 
          <box> 
           <topPen lineWidth="0.5"/> 
           <leftPen lineWidth="0.5"/> 
           <bottomPen lineWidth="0.5"/> 
           <rightPen lineWidth="0.5"/> 
          </box> 
          <textElement textAlignment="Center" verticalAlignment="Middle"/> 
          <textFieldExpression><![CDATA[$V{col3_MEASURE1} != null ? DateFormat.getDateInstance(DateFormat.SHORT, new Locale($P{Locale}.split("-")[0], $P{Locale}.split("-")[1])).format(DateUtils.addMinutes($V{col3_MEASURE1},$P{UtcOffSet})) : null]]></textFieldExpression> 
         </textField> 
        </cellContents> 
       </crosstabCell> 
       <crosstabCell width="60" height="20" columnTotalGroup="col41"> 
        <cellContents mode="Opaque" style="Crosstab_CT"> 
         <textField> 
          <reportElement x="0" y="0" width="60" height="10" forecolor="#FFFFFF" uuid="2576b9e2-3bba-40e3-aa15-5f4f0aada549"/> 
          <textFieldExpression><![CDATA[$V{col2_MEASURE1}]]></textFieldExpression> 
         </textField> 
         <textField> 
          <reportElement x="0" y="10" width="60" height="10" forecolor="#FFFFFF" uuid="a111181f-b60f-4afd-8292-9e260c1b9ce2"/> 
          <textFieldExpression><![CDATA[$V{col3_MEASURE1}]]></textFieldExpression> 
         </textField> 
        </cellContents> 
       </crosstabCell> 
       <crosstabCell width="60" height="20" rowTotalGroup="col11"> 
        <cellContents mode="Opaque" style="Crosstab_CT"> 
         <textField> 
          <reportElement x="0" y="0" width="60" height="10" forecolor="#FFFFFF" uuid="9adf6c9c-acee-4673-8b70-a376e7d1cbb4"/> 
          <textFieldExpression><![CDATA[$V{col2_MEASURE1}]]></textFieldExpression> 
         </textField> 
         <textField> 
          <reportElement x="0" y="10" width="60" height="10" forecolor="#FFFFFF" uuid="9baedeed-4770-4153-b639-afc0965e9467"/> 
          <textFieldExpression><![CDATA[$V{col3_MEASURE1}]]></textFieldExpression> 
         </textField> 
        </cellContents> 
       </crosstabCell> 
       <crosstabCell width="60" height="20" rowTotalGroup="col11" columnTotalGroup="col41"> 
        <cellContents mode="Opaque" style="Crosstab_CT"> 
         <textField> 
          <reportElement x="0" y="0" width="60" height="10" forecolor="#FFFFFF" uuid="a2805e0a-080d-42be-ad86-a7e8e666f571"/> 
          <textFieldExpression><![CDATA[$V{col2_MEASURE1}]]></textFieldExpression> 
         </textField> 
         <textField> 
          <reportElement x="0" y="10" width="60" height="10" forecolor="#FFFFFF" uuid="c485f69d-91e1-4b19-a8ab-bdbfa3cafcc6"/> 
          <textFieldExpression><![CDATA[$V{col3_MEASURE1}]]></textFieldExpression> 
         </textField> 
        </cellContents> 
       </crosstabCell> 
      </crosstab> 
     </band> 
    </summary> 
</jasperReport> 
+0

Quelles données attendez-vous en conséquence (il est préférable de poster l'image)? –

+0

Toutes mes excuses pour coller le mauvais jrxml. J'ai mis à jour le nouveau jrxml dans la question principale. S'il vous plaît jeter un oeil sur le nouveau code. En outre, j'ai joint une image contenant l'exigence de la façon dont les données doivent ressembler –

+0

'Je ne m'attends à aucune fonction de calcul sur les colonnes de mesure' - Il est habituel de montrer quelques résultats d'agrégation pour les groupes dans le tableau croisé. Vous avez un malentendu sur le fonctionnement du tableau croisé. Vous pouvez ajouter des colonnes avec col2 et col3 et jouer avec des en-têtes cachés et afficher ces valeurs. Dans certains cas, le placement du composant sous-rapport/liste est une bonne variante –

Répondre

1

Si vous voulez éviter héliporté/agrégation pour le groupe de lignes col1, vous pouvez ajouter un deuxième groupe de lignes (sans cellules d'en-tête) qui a des valeurs distinctes pour chaque enregistrement. Par exemple:

 <rowGroup name="RecNo" width="0"> 
      <bucket class="java.lang.Integer"> 
       <bucketExpression>$V{REPORT_COUNT}</bucketExpression> 
      </bucket> 
     </rowGroup>