Hi Paolo,
Have you tried using the evaluationTime="Group" attribute of the
textField?
Then you'd just put the calculation in the textFieldExpression,
something like:
<textField evaluationTime="Group">
<reportElement x="0" y="0" width="18" height="9"/>
<textFieldExpression class="java.math.BigDecimal">
$F{price}.divide($V{priceSubtotal})
</textFieldExpression>
</textField>
I'm not sure if it'll evaluate properly, $F{price} may be gone at
Group time, but it is worth a try.
-jason
On Nov 21, 2005, at 11:45 PM, Jacob,Marco wrote:
That sounds complicated to me. If you do select count(*) in the
title band you will also be able to do that in the select statement
of the report. Why do you use a subreport to calculate?
select a.price, (100/sum(b.price))*a.price
from pricing_table a, pricing_table b
group by a.price;
I'm not sure if not all databases can execute this statement but I
think so.
Regards,
Marco
-----Ursprüngliche Nachricht-----
Von: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
Im Auftrag von Martin Clough
Gesendet: Montag, 21. November 2005 17:57
An: [email protected]
Betreff: Re: [jasperreports-questions] Calculation between a
Field and a Variable
The only way I have been able to achieve this is to have an invisible
sub-report in the report title band which performs the total
calculation (eg select count(*)...) and passes this back as a
variable.
Martin
On 21/11/05, Paolo <[EMAIL PROTECTED]> wrote:
Hello everyone,
my name is Paolo and this is my first email to this list. I used
JasperReports for my thesis project, and now I keep using
it at work.
I would like to ask you all an hint on how to do something.
The thing that I (well, someone else...) desire to do is to have a
column which each value of it is calculated using as
operands a Field
and a Variable. For example, if I have a column "Price" and
the total
of it in the group footer, I would like to have for each price the
percentage of it on the total.
Example:
Price Percentage
----------------------------------------
2.00 20%
3.00 30%
5.00 50%
----------------------------------------
Total 10.00 100%
In this example the column percentage is calculated using the price
Field and the Variable that stores its total in the end of
the group.
I am not sure how to do this... I think I may get that data from the
report's source query but I was looking for a way to do it with
Jasper.
Thank you in advance for any hint,
Paolo
-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc. Get Certified Today
Register for a JBoss Training Course. Free Certification Exam
for All Training Attendees Through End of 2005. For more info visit:
http://ads.osdn.com/?ad_idv28&alloc_id845&op=click
_______________________________________________
jasperreports-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jasperreports-questions
-jason
-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc. Get Certified Today
Register for a JBoss Training Course. Free Certification Exam
for All Training Attendees Through End of 2005. For more info visit:
http://ads.osdn.com/?ad_idv28&alloc_id845&op=click
_______________________________________________
jasperreports-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jasperreports-questions