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

How to add extra column in crosstab?


nizam27391

Recommended Posts

Hi all,

I have this requirement to generate a report with dynamic columns which is the course code. I manage to do this with the crosstab. 

jasper-new-column.PNG.232113c4e1c20c815b10e75f852ee65b.PNG

 

But I have another extra details (GPA,CGPA,Result) which require me to add extra column to the crosstab.The data is retrieved from the database already. I'm not able to do this as there is no option for this.

So any idea on how I can add extra column to the crosstab?

 

Thanks

Link to comment
Share on other sites

  • Replies 5
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

  • 2 years later...

I wasn't able to find a way to add a column without a group, so did the following work around:

In my last column

  • I added a second text field element in the Column Group header
    • CrossTab > Column Groups > Total DateData.Date: This section contains two text fields
                <columnGroup name="dateSet.RecordDate" height="20" totalPosition="End">                    <bucket order="Descending" class="java.sql.Timestamp">                        <bucketExpression><![CDATA[$F{dateSet.RecordDate}]]></bucketExpression>                    </bucket>                    <crosstabHeader>                        <cellContents>                            <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.FreeLayout"/>                        </cellContents>                    </crosstabHeader>                    <crosstabColumnHeader>                        <cellContents mode="Opaque" style="Crosstab_CH">                            <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.FreeLayout"/>                            <property name="com.jaspersoft.studio.unit.width" value="pixel"/>                            <textField pattern="MMM d, yyyy">                                <reportElement mode="Opaque" x="0" y="0" width="70" height="20" forecolor="#FFFFFF" backcolor="#0096D1" uuid="b9639ac1-d6ff-41fd-b066-534a881548a2"/>                                <textFieldExpression><![CDATA[$V{dateSet.RecordDate}]]></textFieldExpression>                            </textField>                        </cellContents>                    </crosstabColumnHeader>                    <crosstabTotalColumnHeader>                        <cellContents mode="Opaque" style="Crosstab_CT">                            <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.FreeLayout"/>                            <property name="com.jaspersoft.studio.unit.width" value="pixel"/>                            <textField>                                <reportElement mode="Opaque" x="0" y="0" width="60" height="20" forecolor="#FFFFFF" backcolor="#0096D1" uuid="b7d8e730-8fca-4b37-b6c0-6d2732444fea"/>                                <textFieldExpression><![CDATA["u0394"]]></textFieldExpression>                            </textField>                            <textField>                                <reportElement mode="Opaque" x="60" y="0" width="60" height="20" forecolor="#FFFFFF" backcolor="#0096D1" uuid="b6884931-0695-4142-9d49-34989de70de2"/>                                <textFieldExpression><![CDATA["Abs " + "u0394"]]></textFieldExpression>                            </textField>                        </cellContents>                    </crosstabTotalColumnHeader>                </columnGroup>[/code]

 

  • I added a second text field element in the Column Group Detail section
    • CrossTab >  DateData.Date/Detail: This section contains two text fields, with each of my $V{Variable_Measures}
<crosstabCell width="120" height="20" columnTotalGroup="dateSet.RecordDate">    <cellContents mode="Opaque" style="Crosstab_CT">        <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.FreeLayout"/>        <textField pattern="#,##0.00">            <reportElement mode="Opaque" x="0" y="0" width="60" height="20" forecolor="#000000" uuid="a753ecb5-d682-4ffc-8f41-3b4e8f6cce98"/>            <textElement textAlignment="Right" verticalAlignment="Middle">                <font fontName="DejaVu Sans" size="10"/>            </textElement>            <textFieldExpression><![CDATA[$V{Diff_Measure}]]></textFieldExpression>        </textField>        <textField pattern="#,##0.00">            <reportElement mode="Opaque" x="60" y="0" width="60" height="20" forecolor="#000000" uuid="01e6bcd2-b0e4-4bb7-a353-6221af88415b"/>            <textElement textAlignment="Right" verticalAlignment="Middle">                <font fontName="DejaVu Sans" size="10"/>            </textElement>            <textFieldExpression><![CDATA[$V{AbsDiff_Measure}]]></textFieldExpression>        </textField>    </cellContents></crosstabCell>[/code]
  • Apologies, i don't seem to have permission to upload a screenshot, but src code above
  • Im sure it's more complicated when your crosstab contains totals, mine was fortunately a very simple crosstab

 

 

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