Reputation: 23
DB Table - RunRecord
Name Student_ID Meter(m) Time(s)
ABC 1016 100 13
ABC 1016 200 26
ACB 1017 100 15
BAA 1018 100 18
BAA 1018 200 22
BBB 1019 100 14
CDE 1020 200 22
CDE 1020 100 14
What should I do so that I can get the following result in Jasper Report?
Student Run Record
ABC ACB BAA BBB CDE
100M 13 15 18 14 14
200M 26 22 22
Upvotes: 0
Views: 2833
Reputation: 1
Change the bucket expression of report row group. Make the bucket expression by concatenation of few fields. eg:
<bucket class="java.lang.String">
<bucketExpression><![CDATA[$F{field1}+""+$F{field2}]]></bucketExpression>
</bucket>
Upvotes: 0
Reputation: 3119
You can achieve this by using a crosstab
element.
I used the query as provided by you, I have in my sample these fields:
Drag and drop the crosstab
from the Palette into the summary band of the report in the Report Designer, a wizard will pop up.
Follow the wizard:
Once the crosstab is added click in the Report Inspector and expand the crosstab, click on row groups > Meter and in the Properties panel select as Total Position:None
. Same for Column Groups > Name.
The output will be then as shown in the image below.
In order to get the output closer to what you drafted in your query:
java.lang.String
. Then in the designer edit the field that holds $V{Meter}
and change it to $V{Meter} + "m"
to have output 100m instead of 100.$V{TimeMeasure}
to $V{TimeMeasure} == 0 ? null : $V{TimeMeasure}
. In the Properties Panel check the box for property Blank when null.Upvotes: 3