Jump to content
We've recently updated our Privacy Statement, available here ×

crosstab measure of type string


jaapandre

Recommended Posts

I'm a newbie concerning jasper reports and java :-( But JasperReports (and java) sounds promissing so I'm trying to generate a report using ireport  (3.7.2) with crosstabs.

In the database I have row_id and row_text. In the crosstab I want to use both these fields

I use  $F{row_id} for the bucket expression for the 'row groups' which creates $V{row_id} and I think I need to use 'Measures' to be able to use the row_text. Unfortunately I didn't succeed to create this measure.

I tried:

name: row_text

measure class: java.lang.string

value expression: $F{row_text}

Calculation: first

 

But if I use this variable in the report it returns 'null'.

I hope somebody could help.

 

Jaap-Andre, there doesn't exist stupid questions, only stupid questioners


Link to comment
Share on other sites

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

Thanks for your reaction.

Below you find some parts of the jrxml, which (I think) are relevant.

    <field name="row_id" class="java.lang.String"/>
    <field name="row_text" class="java.lang.String"/>
    <field name="col" class="java.lang.String"/>
    <field name="title_row" class="java.lang.String"/>
    <field name="title_col" class="java.lang.String"/>
    <field name="val" class="java.lang.String"/>


          <measure name="row_text" class="java.lang.String" calculation="First">
                     <measureExpression><![CDATA[$F{row_text}]]></measureExpression>
         </measure>


        <rowGroup name="row" width="258" totalPosition="End">
                    <bucket>
                        <bucketExpression class="java.lang.String"><![CDATA[$F{row_id}]]></bucketExpression>
                    </bucket>
                    <crosstabRowHeader>
                        <cellContents mode="Opaque">
                            <box leftPadding="0">
                            </box>
                            <textField isStretchWithOverflow="true">
                                <reportElement style="Crosstab Data Text" x="0" y="0" width="258" height="15"/>
                                <box>
                                </box>
                            <textFieldExpression class="java.lang.String"><![CDATA[$V{row}+": "+$V{row_text}]]></textFieldExpression>
                            </textField>
                        </cellContents>
                    </crosstabRowHeader>
                    <crosstabTotalRowHeader>
                        <cellContents mode="Opaque">
                            <box rightPadding="0">
                            </box>
                        </cellContents>
                    </crosstabTotalRowHeader>
                </rowGroup>

Link to comment
Share on other sites

Hi,

 

Just to bring some closure to this and confirm that you indeed need to create an additional bucket for the row_text field, regardless if it actually breaks the same way as the row_id bucket. This is the only way to make that row_text value appear correctly in a row header.

 

I hope this helps.
Teodor

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...