Hi

You can create a variable to hold the value used for grouping:
<variable name="groupVal" class="java.lang.Object">
   <variableExpression>
$P{grpHeader}.equals("city") ? $F{city} : ($P{grpHeader}.equals("state") ? $F{state} : ... )
    </variableExpression>
</variable>
and then group by $V{groupVal}

Note that specifying a group in a report does not sort the data set, so you will probably need to sort it depending on your parameter value:
<query>select ... order by $P!{grpHeader}</query>

Then, in the group header you can use printWhenExpression to decide which header to show (city, state, etc).


HTH,
Lucian


Doug James wrote:
Amar, thanks for the reply.

My apologies for not explaining things completely. What I would like to
do is change the field in a grouping band on the actual report as well
as in the query. So in the jrxml I have something like:
<group
name="grouped"><groupExpression><![CDATA[$F{$P{grpHeader}}]]></groupExpr
ession>

I hope this helps explain things further.

Doug

-----Original Message-----
From: Amar Patel [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 01, 2006 4:53 AM
To: Doug James; jasperreports-questions@lists.sourceforge.net
Subject: RE: [jasperreports-questions] Dynamic grouping

hi,

It is possible to pass a parameter in to your template which will run
the query accordingly and fill ur report. For example:
<parameter name="Flag" class="java.lang.String"/>
<queryString><![CDATA[select * from ...group by
$P{Flag}]]></queryString>

I hope that this is what you were looking for.

Thanks
-Amar


-----Original Message-----
From: Doug James [mailto:[EMAIL PROTECTED]
Sent: Tuesday, February 28, 2006 8:02 PM
To: jasperreports-questions@lists.sourceforge.net
Subject: [jasperreports-questions] Dynamic grouping


We have a report that is currently implemented in a different reporting
product. To satisfy our user requirements we have ended up with 3
different report templates to support the 3 different grouping that can
be requested. For example: One template groups by city, another by state
and the final by area code.

Is it possible to pass a parameter into a Jasper Report template that
would allow for one template and the 3 different groupings. We would
like to be able to call the report and pass in the city flag or the
state flag etc.

Thanks for the assistance!
Doug James
Software Engineer
Benefitfocus.com, Inc.



************************************************************************
****
************
BENEFITFOCUS.COM CONFIDENTIALITY NOTICE: This electronic message is
intended only for the individual or entity to which it is addressed and
may contain information that is confidential and protected by law.
Unauthorized review, use, disclosure, or dissemination of this
communication or its contents in any way is prohibited and may be
unlawful. If you are not the intended recipient or a person responsible
for delivering this message to an intended recipient, please notify the
original sender immediately by e-mail or telephone, return the original
message to the original sender or to [EMAIL PROTECTED], and
destroy all copies or derivations of the original message. Thank you.
(BFeComNote Rev. 08/01/2005)
************************************************************************
****
***********


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting
language that extends applications into web and mobile media. Attend the
live webcast and join the prime developer group breaking into this new
coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
jasperreports-questions mailing list
jasperreports-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jasperreports-questions


****************************************************************************************
BENEFITFOCUS.COM CONFIDENTIALITY NOTICE: This electronic message is intended 
only for the individual or entity to which it is addressed and may contain 
information that is confidential and protected by law. Unauthorized review, 
use, disclosure, or dissemination of this communication or its contents in any 
way is prohibited and may be unlawful. If you are not the intended recipient or 
a person responsible for delivering this message to an intended recipient, 
please notify the original sender immediately by e-mail or telephone, return 
the original message to the original sender or to [EMAIL PROTECTED], and 
destroy all copies or derivations of the original message. Thank you.  
(BFeComNote Rev. 08/01/2005)
***************************************************************************************


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=k&kid0944&bid$1720&dat1642
_______________________________________________
jasperreports-questions mailing list
jasperreports-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jasperreports-questions


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
jasperreports-questions mailing list
jasperreports-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jasperreports-questions

Reply via email to