title: JasperReports Dynamic Grouping
body: <p>sorry for opening this question.i would like to somebody tell me how to archive this because a i have the same problem but i don't get the desired results or <a href="https://stackoverflow.com/questions/8587511/jasperreports-grouping-changeable-by-user?answertab=oldest#tab-top">this</a> question presumes its possible but i don't get the same.</p>
  
  <p>and i shall continue with my work</p>
  
  <pre><code>&lt;jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="detailVisitShop" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" scriptletClass="net.sf.jasperreports.engine.JRDefaultScriptlet" uuid="4c82ee8a-2708-4b04-a1f3-b213d6c4c380"&gt;
      &lt;property name="ireport.zoom" value="1.0"/&gt;
      &lt;property name="ireport.x" value="0"/&gt;
      &lt;property name="ireport.y" value="0"/&gt;
      &lt;style name="Title" fontName="Times New Roman" fontSize="50" isBold="true" pdfFontName="Times-Bold"/&gt;
      &lt;style name="SubTitle" forecolor="#736343" fontName="Arial" fontSize="18"/&gt;
      &lt;style name="Column header" forecolor="#666666" fontName="Arial" fontSize="12" isBold="true"/&gt;
      &lt;style name="Detail" fontName="Arial" fontSize="16"/&gt;
      &lt;style name="Row" mode="Transparent"&gt;
          &lt;conditionalStyle&gt;
              &lt;conditionExpression&gt;&lt;![CDATA[$V{REPORT_COUNT}%2 == 0]]&gt;&lt;/conditionExpression&gt;
              &lt;style backcolor="#E6DAC3"/&gt;
          &lt;/conditionalStyle&gt;
      &lt;/style&gt;
      &lt;parameter name="idCliente" class="java.lang.Integer"&gt;
          &lt;defaultValueExpression&gt;&lt;![CDATA[3]]&gt;&lt;/defaultValueExpression&gt;
      &lt;/parameter&gt;
      &lt;parameter name="grpHeader" class="java.lang.String"&gt;
          &lt;defaultValueExpression&gt;&lt;![CDATA[]]&gt;&lt;/defaultValueExpression&gt;
      &lt;/parameter&gt;
      &lt;queryString&gt;
          &lt;![CDATA[SELECT
      Cv.condicionventaname 'CondicionVenta',
      concat(Cl.`names`, ' ', Cl.lastnames) 'Cliente',
      U.userName 'Operador',
      V.fecha,
      V.Total,V.idventa,v.cliente_idcliente,
      case
          when Cv.idcondicionventa = 1 then concat('Folio ', cast(V.folio as char))
          else concat('Factura ', cast(V.factura as char))
      end as 'Numero de operacion',
      case
          when V.cars_numberplate is not null then concat('Placas ' , V.cars_numberplate)
          when V.climas_idclimas  is not null then concat('Numero de serie ', V.climas_idclimas)
      end as 'Servicio A', V.cars_numberplate placas,V.climas_idclimas clima,U.userName 
  from
      Ventas V
          left join
      Climas cli ON Cli.idclimas = V.climas_idclimas
          left join
      Cars ca ON Ca.numberplate = V.cars_numberplate
          left join
      condicionventa Cv ON Cv.idcondicionventa = V.condicionventa_idcondicionventa
         inner join
      cliente Cl ON Cl.idcliente = V.cliente_idcliente
          inner join
      users U ON U.iduser = V.Users_idUser
  order by $P{grpHeader}]]&gt;
      &lt;/queryString&gt;
      &lt;field name="CondicionVenta" class="java.lang.String"/&gt;
      &lt;field name="Cliente" class="java.lang.String"/&gt;
      &lt;field name="Operador" class="java.lang.String"/&gt;
      &lt;field name="fecha" class="java.sql.Timestamp"/&gt;
      &lt;field name="Total" class="java.lang.Double"/&gt;
      &lt;field name="idventa" class="java.lang.Integer"/&gt;
      &lt;field name="cliente_idcliente" class="java.lang.Integer"/&gt;
      &lt;field name="Numero de operacion" class="java.lang.String"/&gt;
      &lt;field name="Servicio A" class="java.lang.String"/&gt;
      &lt;field name="placas" class="java.lang.String"/&gt;
      &lt;field name="clima" class="java.lang.String"/&gt;
      &lt;field name="userName" class="java.lang.String"/&gt;
      &lt;variable name="variable1" class="java.lang.Double" resetType="Group" resetGroup="Group1" calculation="Sum"&gt;
          &lt;variableExpression&gt;&lt;![CDATA[$F{Total}]]&gt;&lt;/variableExpression&gt;
      &lt;/variable&gt;
      &lt;variable name="groupVal" class="java.lang.Object"&gt;
          &lt;variableExpression&gt;&lt;![CDATA[$P{grpHeader}.equals("Placas") ? 
              $F{placas} : ($P{grpHeader}.equals("cliente") ? $F{Cliente} : $F{Cliente} )]]&gt;&lt;/variableExpression&gt;
      &lt;/variable&gt;
      &lt;variable name="numberOfVisits" class="java.lang.Integer" resetType="Group" resetGroup="Group1" calculation="Count"&gt;
          &lt;variableExpression&gt;&lt;![CDATA[$F{idventa}]]&gt;&lt;/variableExpression&gt;
      &lt;/variable&gt;
      &lt;group name="Group1"&gt;
          &lt;groupExpression&gt;&lt;![CDATA[$P{grpHeader}]]&gt;&lt;/groupExpression&gt;
          &lt;groupHeader&gt;
              &lt;band height="37"&gt;
                  &lt;frame&gt;
                      &lt;reportElement uuid="b6aeacfd-18df-4b4e-8d03-b205cd4e0509" mode="Opaque" x="-21" y="7" width="843" height="24" forecolor="#B89F7D" backcolor="#F2EBDF"/&gt;
                      &lt;textField&gt;
                          &lt;reportElement uuid="87ff53e3-0507-4a1a-983d-c25f21767513" style="SubTitle" x="68" y="0" width="755" height="24" forecolor="#736343"/&gt;
                          &lt;textElement&gt;
                              &lt;font isBold="true"/&gt;
                          &lt;/textElement&gt;
                          &lt;textFieldExpression&gt;&lt;![CDATA[$F{placas}]]&gt;&lt;/textFieldExpression&gt;
                      &lt;/textField&gt;
                  &lt;/frame&gt;
              &lt;/band&gt;
          &lt;/groupHeader&gt;
          &lt;groupFooter&gt;
              &lt;band height="26"&gt;
                  &lt;rectangle&gt;
                      &lt;reportElement uuid="0a5f2335-ad9e-4a8c-8b77-0a2f5ffcfb2d" mode="Opaque" x="-1" y="0" width="802" height="25" forecolor="#FFFFFF" backcolor="#838E8E"/&gt;
                  &lt;/rectangle&gt;
                  &lt;textField pattern="¤ #,##0.00" isBlankWhenNull="true"&gt;
                      &lt;reportElement uuid="7fb963f9-825a-498f-9635-98614f1f0893" x="559" y="5" width="202" height="20" forecolor="#FFCC00"/&gt;
                      &lt;textElement&gt;
                          &lt;font size="14"/&gt;
                      &lt;/textElement&gt;
                      &lt;textFieldExpression&gt;&lt;![CDATA[$V{variable1}]]&gt;&lt;/textFieldExpression&gt;
                  &lt;/textField&gt;
                  &lt;textField pattern="¤ #,##0.00" isBlankWhenNull="true"&gt;
                      &lt;reportElement uuid="19e30ce4-bcd7-4763-87c8-20f95a64461a" x="459" y="0" width="100" height="25"/&gt;
                      &lt;textElement textAlignment="Center" verticalAlignment="Bottom"&gt;
                          &lt;font size="16"/&gt;
                      &lt;/textElement&gt;
                      &lt;textFieldExpression&gt;&lt;![CDATA["Total"]]&gt;&lt;/textFieldExpression&gt;
                  &lt;/textField&gt;
                  &lt;textField pattern="¤ #,##0.00" isBlankWhenNull="true"&gt;
                      &lt;reportElement uuid="06e8276f-7143-4c0e-ad9f-336fabbead33" x="1" y="0" width="171" height="25"/&gt;
                      &lt;textElement verticalAlignment="Middle"&gt;
                          &lt;font size="16"/&gt;
                      &lt;/textElement&gt;
                      &lt;textFieldExpression&gt;&lt;![CDATA["Numero de vistas"]]&gt;&lt;/textFieldExpression&gt;
                  &lt;/textField&gt;
                  &lt;textField pattern="" isBlankWhenNull="true"&gt;
                      &lt;reportElement uuid="e22bb9e4-770e-45cf-b4eb-30d7a0c50633" x="195" y="6" width="202" height="20"/&gt;
                      &lt;textElement&gt;
                          &lt;font size="14"/&gt;
                      &lt;/textElement&gt;
                      &lt;textFieldExpression&gt;&lt;![CDATA[$V{numberOfVisits}]]&gt;&lt;/textFieldExpression&gt;
                  &lt;/textField&gt;
              &lt;/band&gt;
          &lt;/groupFooter&gt;
      &lt;/group&gt;
  </code></pre>
  
  <p>also i checked other sources like <a href="http://www.mail-archive.com/jasperreports-questions@lists.sourceforge.net/msg00239.html" rel="nofollow noreferrer">this</a> but i couldn't accomplish my goal. so this is impossible or i' doing it wrong?</p>