Search code examples
jsonjasper-reportscrosstab

How to show row total and column total in crosstab?


I have below json for weekly purchase. Crosstab is used to show weekly purchase of each products. There is target field which is included as rowgroup in the crosstab . When i total targets and weekly the calculation of total target is incorrect.

How can we get total of totals?

sample json.

{
    "header": {
        "columnName": [
            "Product Store1",
            "location"
        ],
        "values": [{
                "purchase": {
                    "id":"purchase1001",
                    "name": "bags",
                    "location": "MainMarket "
                },
                "targets":{
                    "weekly":300
                },
                "weekSpend": [{
                        "weekStartDate": 20181105,
                        "spend": 100

                    },
                    {
                        "weekStartDate": 20181112,
                        "spend": 200

                    }
                ]
            },
            {
                "purchase": {
                    "id":"purchase1002",
                    "name": "shoes",
                    "location": "MainMarket "
                },
                "targets":{
                    "weekly":400
                },
                "weekSpend": [{
                        "weekStartDate": 20181105,
                        "spend": 100

                    },
                    {
                        "weekStartDate": 20181112,
                        "spend": 200

                    }
                ]
            }
        ]
    }
}

I tried following this link https://community.jaspersoft.com/wiki/incorrect-crosstab-row-group-total-arising-dataset-created-using-right-outer-join But creating group using product name is giving compilation error.

JRXML that has error total

<?xml version="1.0" encoding="UTF-8"?>
<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="XTabReport" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="33c43d53-f9b3-4cc9-92b2-bedd805d66a9">
    <style name="Crosstab_CH" mode="Opaque" backcolor="#F0F8FF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
            <topPen lineWidth="0.5" lineColor="#000000"/>
            <leftPen lineWidth="0.5" lineColor="#000000"/>
            <bottomPen lineWidth="0.5" lineColor="#000000"/>
            <rightPen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="Crosstab_CG" mode="Opaque" backcolor="#BFE1FF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
            <topPen lineWidth="0.5" lineColor="#000000"/>
            <leftPen lineWidth="0.5" lineColor="#000000"/>
            <bottomPen lineWidth="0.5" lineColor="#000000"/>
            <rightPen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="Crosstab_CT" mode="Opaque" backcolor="#005FB3">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
            <topPen lineWidth="0.5" lineColor="#000000"/>
            <leftPen lineWidth="0.5" lineColor="#000000"/>
            <bottomPen lineWidth="0.5" lineColor="#000000"/>
            <rightPen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="Crosstab_CD" mode="Opaque" backcolor="#FFFFFF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
            <topPen lineWidth="0.5" lineColor="#000000"/>
            <leftPen lineWidth="0.5" lineColor="#000000"/>
            <bottomPen lineWidth="0.5" lineColor="#000000"/>
            <rightPen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <subDataset name="XTabDS" uuid="9911fa6c-61b7-4952-81bf-4666e3e17fcf">
        <field name="weekStartDate" class="java.lang.Integer">
            <property name="net.sf.jasperreports.jsonql.field.expression" value="weekStartDate"/>
        </field>
        <field name="spend" class="java.lang.Integer">
            <property name="net.sf.jasperreports.jsonql.field.expression" value="spend"/>
        </field>
        <field name="name" class="java.lang.String">
            <property name="net.sf.jasperreports.jsonql.field.expression" value="^{2}.purchase.name"/>
        </field>
        <field name="location" class="java.lang.String">
            <property name="net.sf.jasperreports.jsonql.field.expression" value="^{2}.purchase.location"/>
        </field>
        <field name="target" class="java.lang.Integer">
            <property name="net.sf.jasperreports.jsonql.field.expression" value="^{2}.targets.weekly"/>
        </field>
    </subDataset>
    <subDataset name="listSubDataset" uuid="01e76955-f29e-4d52-991b-aa0149bfdb37">
        <field name="colName" class="java.lang.String">
            <property name="net.sf.jasperreports.jsonql.field.expression" value="[0]"/>
        </field>
    </subDataset>
    <queryString language="jsonql">
        <![CDATA[]]>
    </queryString>
    <title>
        <band height="58">
            <staticText>
                <reportElement x="140" y="10" width="280" height="30" uuid="c8e3d7ad-eeb0-4cd1-8bef-88874e6921d4"/>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font size="14"/>
                </textElement>
                <text><![CDATA[List inside Crosstab]]></text>
            </staticText>
        </band>
    </title>
    <detail>
        <band height="70" splitType="Stretch">
            <crosstab>
                <reportElement x="0" y="0" width="560" height="70" uuid="79f2afae-ac8b-4442-ac8e-ae1b1f68109f">
                    <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/>
                    <property name="com.jaspersoft.studio.crosstab.style.header" value="Crosstab_CH"/>
                    <property name="com.jaspersoft.studio.crosstab.style.group" value="Crosstab_CG"/>
                    <property name="com.jaspersoft.studio.crosstab.style.total" value="Crosstab_CT"/>
                    <property name="com.jaspersoft.studio.crosstab.style.detail" value="Crosstab_CD"/>
                </reportElement>
                <crosstabParameter name="listDS" class="net.sf.jasperreports.engine.data.JsonQLDataSource">
                    <parameterValueExpression><![CDATA[((net.sf.jasperreports.engine.data.JsonQLDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("header.columnName")]]></parameterValueExpression>
                </crosstabParameter>
                <crosstabDataset>
                    <dataset>
                        <datasetRun subDataset="XTabDS" uuid="73b2e155-5015-451a-8813-7e2ed2f731fb">
                            <dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JsonQLDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("..values..weekSpend.*")]]></dataSourceExpression>
                        </datasetRun>
                    </dataset>
                </crosstabDataset>
                <crosstabHeaderCell>
                    <cellContents mode="Opaque" style="Crosstab_CD">
                        <componentElement>
                            <reportElement x="0" y="0" width="180" height="30" isPrintWhenDetailOverflows="true" uuid="412c6db7-0cfa-4025-80cd-8c450f9eab96">
                                <property name="net.sf.jasperreports.export.headertoolbar.table.name" value=""/>
                            </reportElement>
                            <jr:list xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd" printOrder="Horizontal">
                                <datasetRun subDataset="listSubDataset" uuid="a911c80f-a0b3-4395-bbd7-2c52c67585d3">
                                    <dataSourceExpression><![CDATA[$P{listDS}]]></dataSourceExpression>
                                </datasetRun>
                                <jr:listContents height="30" width="90">
                                    <textField>
                                        <reportElement x="0" y="0" width="90" height="30" isPrintWhenDetailOverflows="true" uuid="168fd030-81cf-4b80-9766-6f4637c779ec"/>
                                        <box>
                                            <topPen lineWidth="0.5"/>
                                            <leftPen lineWidth="0.5"/>
                                        </box>
                                        <textElement>
                                            <paragraph leftIndent="3" spacingBefore="3"/>
                                        </textElement>
                                        <textFieldExpression><![CDATA[$F{colName}]]></textFieldExpression>
                                    </textField>
                                </jr:listContents>
                            </jr:list>
                        </componentElement>
                    </cellContents>
                </crosstabHeaderCell>
                <rowGroup name="name" width="90" totalPosition="End">
                    <bucket class="java.lang.String">
                        <bucketExpression><![CDATA[$F{name}]]></bucketExpression>
                    </bucket>
                    <crosstabRowHeader>
                        <cellContents mode="Opaque" style="Crosstab_CH">
                            <textField>
                                <reportElement x="0" y="0" width="90" height="20" uuid="e8aa37d7-0921-40a6-8aca-1cccae61d26d"/>
                                <textElement>
                                    <paragraph leftIndent="3" spacingBefore="3"/>
                                </textElement>
                                <textFieldExpression><![CDATA[$V{name}]]></textFieldExpression>
                            </textField>
                        </cellContents>
                    </crosstabRowHeader>
                    <crosstabTotalRowHeader>
                        <cellContents mode="Opaque" style="Crosstab_CT">
                            <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.FreeLayout"/>
                            <textField>
                                <reportElement x="182" y="0" width="80" height="20" uuid="ff76ebdd-1c14-4924-8bff-392beb7ef1b3"/>
                                <textFieldExpression><![CDATA[$V{totaltargets}]]></textFieldExpression>
                            </textField>
                        </cellContents>
                    </crosstabTotalRowHeader>
                </rowGroup>
                <rowGroup name="location" width="90" totalPosition="End">
                    <bucket class="java.lang.String">
                        <bucketExpression><![CDATA[$F{location}]]></bucketExpression>
                    </bucket>
                    <crosstabRowHeader>
                        <cellContents mode="Opaque" style="Crosstab_CH">
                            <textField>
                                <reportElement x="0" y="0" width="90" height="20" uuid="86107a55-79be-4170-a2ee-b2a0ae5315e2"/>
                                <textElement>
                                    <paragraph leftIndent="3" spacingBefore="3"/>
                                </textElement>
                                <textFieldExpression><![CDATA[$V{location}]]></textFieldExpression>
                            </textField>
                        </cellContents>
                    </crosstabRowHeader>
                    <crosstabTotalRowHeader>
                        <cellContents mode="Opaque" style="Crosstab_CG"/>
                    </crosstabTotalRowHeader>
                </rowGroup>
                <rowGroup name="target" width="90">
                    <bucket class="java.lang.Integer">
                        <bucketExpression><![CDATA[$F{target}]]></bucketExpression>
                    </bucket>
                    <crosstabRowHeader>
                        <cellContents mode="Opaque" style="Crosstab_CH">
                            <textField>
                                <reportElement x="0" y="0" width="90" height="20" uuid="3c9c5be2-4ced-4db6-8dd2-0f411281cce6"/>
                                <textFieldExpression><![CDATA[$V{target}]]></textFieldExpression>
                            </textField>
                        </cellContents>
                    </crosstabRowHeader>
                    <crosstabTotalRowHeader>
                        <cellContents mode="Opaque" style="Crosstab_CG">
                            <staticText>
                                <reportElement x="0" y="0" width="90" height="20" uuid="e14fddff-9658-4dcf-b6a7-78e195e2bba4"/>
                                <text><![CDATA[Total target]]></text>
                            </staticText>
                        </cellContents>
                    </crosstabTotalRowHeader>
                </rowGroup>
                <columnGroup name="weekStartDate" height="30" totalPosition="End">
                    <bucket class="java.lang.Integer">
                        <bucketExpression><![CDATA[$F{weekStartDate}]]></bucketExpression>
                    </bucket>
                    <crosstabColumnHeader>
                        <cellContents mode="Opaque" style="Crosstab_CH">
                            <textField>
                                <reportElement x="0" y="0" width="90" height="30" uuid="c65fb64a-d89b-4cc3-be28-d76624cb3d93"/>
                                <textElement>
                                    <paragraph leftIndent="3" spacingBefore="3"/>
                                </textElement>
                                <textFieldExpression><![CDATA[$V{weekStartDate}]]></textFieldExpression>
                            </textField>
                        </cellContents>
                    </crosstabColumnHeader>
                    <crosstabTotalColumnHeader>
                        <cellContents mode="Opaque" style="Crosstab_CT"/>
                    </crosstabTotalColumnHeader>
                </columnGroup>
                <measure name="spend_MEASURE" class="java.lang.Integer">
                    <measureExpression><![CDATA[$F{spend}]]></measureExpression>
                </measure>
                <measure name="totalspend_MEASURE" class="java.lang.Integer" calculation="Sum">
                    <measureExpression><![CDATA[$F{spend}]]></measureExpression>
                </measure>
                <measure name="totaltargets" class="java.lang.Integer" calculation="Sum">
                    <measureExpression><![CDATA[$F{target}]]></measureExpression>
                </measure>
                <crosstabCell width="90" height="20">
                    <cellContents mode="Opaque" style="Crosstab_CD">
                        <textField>
                            <reportElement x="0" y="0" width="90" height="20" uuid="efb4b6dd-d9d3-4520-a94e-c0010a572b29"/>
                            <textElement>
                                <paragraph leftIndent="3" spacingBefore="3"/>
                            </textElement>
                            <textFieldExpression><![CDATA[$V{spend_MEASURE}]]></textFieldExpression>
                        </textField>
                    </cellContents>
                </crosstabCell>
                <crosstabCell height="20" columnTotalGroup="weekStartDate">
                    <cellContents mode="Opaque" style="Crosstab_CT"/>
                </crosstabCell>
                <crosstabCell width="90" height="0" rowTotalGroup="location">
                    <cellContents mode="Opaque" style="Crosstab_CG"/>
                </crosstabCell>
                <crosstabCell height="0" rowTotalGroup="location" columnTotalGroup="weekStartDate">
                    <cellContents mode="Opaque" style="Crosstab_CT"/>
                </crosstabCell>
                <crosstabCell width="90" height="20" rowTotalGroup="name">
                    <cellContents mode="Opaque" style="Crosstab_CT">
                        <textField>
                            <reportElement x="0" y="0" width="90" height="20" uuid="9dbc6e03-7cac-4daa-af1a-a8b7b3b6b97c"/>
                            <textFieldExpression><![CDATA[$V{totalspend_MEASURE}]]></textFieldExpression>
                        </textField>
                    </cellContents>
                </crosstabCell>
                <crosstabCell height="20" rowTotalGroup="name" columnTotalGroup="weekStartDate">
                    <cellContents mode="Opaque" style="Crosstab_CT"/>
                </crosstabCell>
                <crosstabCell width="90" height="20" rowTotalGroup="target">
                    <cellContents mode="Opaque" style="Crosstab_CG"/>
                </crosstabCell>
                <crosstabCell height="20" rowTotalGroup="target" columnTotalGroup="weekStartDate">
                    <cellContents mode="Opaque" style="Crosstab_CT"/>
                </crosstabCell>
            </crosstab>
        </band>
    </detail>
</jasperReport>

The output with wrong totals:

enter image description here


Solution

  • I was able to get total for row columns by defining group name in the data set used by crosstab.

    Below is the final layout

    enter image description here

    Below is the modified jrxml notice the data set XTabDS has a group tag for id.

    <?xml version="1.0" encoding="UTF-8"?>
    <!-- Created with Jaspersoft Studio version 6.6.0.final using JasperReports Library version 6.6.0  -->
    <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="XTabReport" pageWidth="1000" pageHeight="595" orientation="Landscape" columnWidth="960" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="33c43d53-f9b3-4cc9-92b2-bedd805d66a9">
        <property name="com.jaspersoft.studio.data.defaultdataadapter" value="release\AOS 19.4\SampleAdapter.xml"/>
        <property name="com.jaspersoft.studio.unit." value="pixel"/>
        <property name="com.jaspersoft.studio.unit.pageHeight" value="pixel"/>
        <property name="com.jaspersoft.studio.unit.pageWidth" value="pixel"/>
        <property name="com.jaspersoft.studio.unit.topMargin" value="pixel"/>
        <property name="com.jaspersoft.studio.unit.bottomMargin" value="pixel"/>
        <property name="com.jaspersoft.studio.unit.leftMargin" value="pixel"/>
        <property name="com.jaspersoft.studio.unit.rightMargin" value="pixel"/>
        <property name="com.jaspersoft.studio.unit.columnWidth" value="pixel"/>
        <property name="com.jaspersoft.studio.unit.columnSpacing" value="pixel"/>
        <style name="Crosstab_CH" mode="Opaque" backcolor="#F0F8FF">
            <box>
                <pen lineWidth="0.5" lineColor="#000000"/>
                <topPen lineWidth="0.5" lineColor="#000000"/>
                <leftPen lineWidth="0.5" lineColor="#000000"/>
                <bottomPen lineWidth="0.5" lineColor="#000000"/>
                <rightPen lineWidth="0.5" lineColor="#000000"/>
            </box>
        </style>
        <style name="Crosstab_CG" mode="Opaque" backcolor="#BFE1FF">
            <box>
                <pen lineWidth="0.5" lineColor="#000000"/>
                <topPen lineWidth="0.5" lineColor="#000000"/>
                <leftPen lineWidth="0.5" lineColor="#000000"/>
                <bottomPen lineWidth="0.5" lineColor="#000000"/>
                <rightPen lineWidth="0.5" lineColor="#000000"/>
            </box>
        </style>
        <style name="Crosstab_CT" mode="Opaque" backcolor="#005FB3">
            <box>
                <pen lineWidth="0.5" lineColor="#000000"/>
                <topPen lineWidth="0.5" lineColor="#000000"/>
                <leftPen lineWidth="0.5" lineColor="#000000"/>
                <bottomPen lineWidth="0.5" lineColor="#000000"/>
                <rightPen lineWidth="0.5" lineColor="#000000"/>
            </box>
        </style>
        <style name="Crosstab_CD" mode="Opaque" backcolor="#FFFFFF">
            <box>
                <pen lineWidth="0.5" lineColor="#000000"/>
                <topPen lineWidth="0.5" lineColor="#000000"/>
                <leftPen lineWidth="0.5" lineColor="#000000"/>
                <bottomPen lineWidth="0.5" lineColor="#000000"/>
                <rightPen lineWidth="0.5" lineColor="#000000"/>
            </box>
        </style>
        <subDataset name="XTabDS" uuid="9911fa6c-61b7-4952-81bf-4666e3e17fcf">
            <field name="weekStartDate" class="java.lang.Integer">
                <property name="net.sf.jasperreports.jsonql.field.expression" value="weekStartDate"/>
            </field>
            <field name="spend" class="java.lang.Integer">
                <property name="net.sf.jasperreports.jsonql.field.expression" value="spend"/>
            </field>
            <field name="name" class="java.lang.String">
                <property name="net.sf.jasperreports.jsonql.field.expression" value="^{2}.purchase.name"/>
            </field>
            <field name="location" class="java.lang.String">
                <property name="net.sf.jasperreports.jsonql.field.expression" value="^{2}.purchase.location"/>
            </field>
            <field name="id" class="java.lang.String">
                <property name="net.sf.jasperreports.jsonql.field.expression" value="^{2}.purchase.id"/>
            </field>
            <field name="target" class="java.lang.Integer">
                <property name="net.sf.jasperreports.jsonql.field.expression" value="^{2}.targets.weekly"/>
            </field>
            <group name="namegroup">
                <groupExpression><![CDATA[$F{id}]]></groupExpression>
            </group>
        </subDataset>
        <subDataset name="listSubDataset" uuid="01e76955-f29e-4d52-991b-aa0149bfdb37">
            <field name="colName" class="java.lang.String">
                <property name="net.sf.jasperreports.jsonql.field.expression" value="[0]"/>
            </field>
        </subDataset>
        <queryString language="jsonql">
            <![CDATA[]]>
        </queryString>
        <background>
            <band splitType="Stretch"/>
        </background>
        <title>
            <band height="58">
                <staticText>
                    <reportElement x="140" y="10" width="280" height="30" uuid="c8e3d7ad-eeb0-4cd1-8bef-88874e6921d4"/>
                    <textElement textAlignment="Center" verticalAlignment="Middle">
                        <font size="14"/>
                    </textElement>
                    <text><![CDATA[List inside Crosstab]]></text>
                </staticText>
            </band>
        </title>
        <detail>
            <band height="315" splitType="Stretch">
                <crosstab>
                    <reportElement x="0" y="30" width="640" height="250" uuid="79f2afae-ac8b-4442-ac8e-ae1b1f68109f">
                        <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/>
                        <property name="com.jaspersoft.studio.crosstab.style.header" value="Crosstab_CH"/>
                        <property name="com.jaspersoft.studio.crosstab.style.group" value="Crosstab_CG"/>
                        <property name="com.jaspersoft.studio.crosstab.style.total" value="Crosstab_CT"/>
                        <property name="com.jaspersoft.studio.crosstab.style.detail" value="Crosstab_CD"/>
                    </reportElement>
                    <crosstabParameter name="listDS" class="net.sf.jasperreports.engine.data.JsonQLDataSource">
                        <parameterValueExpression><![CDATA[((net.sf.jasperreports.engine.data.JsonQLDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("header.columnName")]]></parameterValueExpression>
                    </crosstabParameter>
                    <crosstabDataset>
                        <dataset>
                            <datasetRun subDataset="XTabDS" uuid="73b2e155-5015-451a-8813-7e2ed2f731fb">
                                <dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JsonQLDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("..values..weekSpend.*")]]></dataSourceExpression>
                            </datasetRun>
                        </dataset>
                    </crosstabDataset>
                    <crosstabHeaderCell>
                        <cellContents mode="Opaque" style="Crosstab_CD">
                            <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.FreeLayout"/>
                            <componentElement>
                                <reportElement x="0" y="0" width="270" height="30" isPrintWhenDetailOverflows="true" uuid="412c6db7-0cfa-4025-80cd-8c450f9eab96">
                                    <property name="net.sf.jasperreports.export.headertoolbar.table.name" value=""/>
                                </reportElement>
                                <jr:list xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd" printOrder="Horizontal" ignoreWidth="false">
                                    <datasetRun subDataset="listSubDataset" uuid="a911c80f-a0b3-4395-bbd7-2c52c67585d3">
                                        <dataSourceExpression><![CDATA[$P{listDS}]]></dataSourceExpression>
                                    </datasetRun>
                                    <jr:listContents height="30" width="270">
                                        <textField>
                                            <reportElement stretchType="ElementGroupBottom" x="0" y="0" width="270" height="30" isPrintWhenDetailOverflows="true" uuid="168fd030-81cf-4b80-9766-6f4637c779ec"/>
                                            <box>
                                                <topPen lineWidth="0.5"/>
                                                <leftPen lineWidth="0.5"/>
                                            </box>
                                            <textElement>
                                                <paragraph leftIndent="3" spacingBefore="3"/>
                                            </textElement>
                                            <textFieldExpression><![CDATA[$F{colName}]]></textFieldExpression>
                                        </textField>
                                    </jr:listContents>
                                </jr:list>
                            </componentElement>
                        </cellContents>
                    </crosstabHeaderCell>
                    <rowGroup name="location" width="90" totalPosition="End">
                        <bucket class="java.lang.String">
                            <bucketExpression><![CDATA[$F{location}]]></bucketExpression>
                        </bucket>
                        <crosstabRowHeader>
                            <cellContents mode="Opaque" style="Crosstab_CH">
                                <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.FreeLayout"/>
                                <textField>
                                    <reportElement x="0" y="0" width="90" height="40" uuid="3f1ee208-60d1-412a-9138-7de26110367c"/>
                                    <textFieldExpression><![CDATA[$V{location}]]></textFieldExpression>
                                </textField>
                            </cellContents>
                        </crosstabRowHeader>
                        <crosstabTotalRowHeader>
                            <cellContents mode="Opaque" style="Crosstab_CG">
                                <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.FreeLayout"/>
                                <textField>
                                    <reportElement x="180" y="0" width="90" height="20" uuid="1e206bac-b8b9-4e65-8d12-57881505a4b2"/>
                                    <textFieldExpression><![CDATA[$V{TOTAL}]]></textFieldExpression>
                                </textField>
                            </cellContents>
                        </crosstabTotalRowHeader>
                    </rowGroup>
                    <rowGroup name="name" width="90">
                        <bucket class="java.lang.String">
                            <bucketExpression><![CDATA[$F{name}]]></bucketExpression>
                        </bucket>
                        <crosstabRowHeader>
                            <cellContents mode="Opaque" style="Crosstab_CH">
                                <textField>
                                    <reportElement x="0" y="0" width="90" height="40" uuid="e8aa37d7-0921-40a6-8aca-1cccae61d26d"/>
                                    <textElement>
                                        <paragraph leftIndent="3" spacingBefore="3"/>
                                    </textElement>
                                    <textFieldExpression><![CDATA[$V{name}]]></textFieldExpression>
                                </textField>
                            </cellContents>
                        </crosstabRowHeader>
                        <crosstabTotalRowHeader>
                            <cellContents mode="Opaque" style="Crosstab_CT">
                                <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.FreeLayout"/>
                                <textField>
                                    <reportElement x="182" y="0" width="80" height="20" uuid="ff76ebdd-1c14-4924-8bff-392beb7ef1b3"/>
                                    <textFieldExpression><![CDATA[$V{TOTAL}]]></textFieldExpression>
                                </textField>
                            </cellContents>
                        </crosstabTotalRowHeader>
                    </rowGroup>
                    <rowGroup name="target" width="90">
                        <bucket class="java.lang.Integer">
                            <bucketExpression><![CDATA[$F{target}]]></bucketExpression>
                        </bucket>
                        <crosstabRowHeader>
                            <cellContents mode="Opaque" style="Crosstab_CH">
                                <textField>
                                    <reportElement x="0" y="0" width="90" height="40" uuid="3c9c5be2-4ced-4db6-8dd2-0f411281cce6"/>
                                    <textFieldExpression><![CDATA[$V{target}]]></textFieldExpression>
                                </textField>
                            </cellContents>
                        </crosstabRowHeader>
                        <crosstabTotalRowHeader>
                            <cellContents mode="Opaque" style="Crosstab_CG">
                                <staticText>
                                    <reportElement x="0" y="0" width="0" height="0" uuid="e14fddff-9658-4dcf-b6a7-78e195e2bba4"/>
                                    <text><![CDATA[Total target]]></text>
                                </staticText>
                            </cellContents>
                        </crosstabTotalRowHeader>
                    </rowGroup>
                    <columnGroup name="weekStartDate" height="30" totalPosition="End">
                        <bucket class="java.lang.Integer">
                            <bucketExpression><![CDATA[$F{weekStartDate}]]></bucketExpression>
                        </bucket>
                        <crosstabColumnHeader>
                            <cellContents mode="Opaque" style="Crosstab_CH">
                                <textField>
                                    <reportElement x="0" y="0" width="90" height="30" uuid="c65fb64a-d89b-4cc3-be28-d76624cb3d93"/>
                                    <textElement>
                                        <paragraph leftIndent="3" spacingBefore="3"/>
                                    </textElement>
                                    <textFieldExpression><![CDATA[$V{weekStartDate}]]></textFieldExpression>
                                </textField>
                            </cellContents>
                        </crosstabColumnHeader>
                        <crosstabTotalColumnHeader>
                            <cellContents mode="Opaque" style="Crosstab_CT"/>
                        </crosstabTotalColumnHeader>
                    </columnGroup>
                    <measure name="spend_MEASURE" class="java.lang.Integer">
                        <measureExpression><![CDATA[$F{spend}]]></measureExpression>
                    </measure>
                    <measure name="totalspend_MEASURE" class="java.lang.Integer" calculation="Sum">
                        <measureExpression><![CDATA[$F{spend}]]></measureExpression>
                    </measure>
                    <measure name="totaltargets" class="java.lang.Integer" calculation="Sum">
                        <measureExpression><![CDATA[$F{target}]]></measureExpression>
                    </measure>
                    <measure name="TOTAL" class="java.lang.Integer" calculation="Sum">
                        <measureExpression><![CDATA[$V{namegroup_COUNT} == 1 ? $F{target} : 0]]></measureExpression>
                    </measure>
                    <crosstabCell width="90" height="40">
                        <cellContents mode="Opaque" style="Crosstab_CD">
                            <textField>
                                <reportElement x="0" y="0" width="90" height="40" uuid="efb4b6dd-d9d3-4520-a94e-c0010a572b29"/>
                                <textElement>
                                    <paragraph leftIndent="3" spacingBefore="3"/>
                                </textElement>
                                <textFieldExpression><![CDATA[$V{spend_MEASURE}]]></textFieldExpression>
                            </textField>
                        </cellContents>
                    </crosstabCell>
                    <crosstabCell height="40" columnTotalGroup="weekStartDate">
                        <cellContents mode="Opaque" style="Crosstab_CT"/>
                    </crosstabCell>
                    <crosstabCell width="90" height="20" rowTotalGroup="name">
                        <cellContents mode="Opaque" style="Crosstab_CT"/>
                    </crosstabCell>
                    <crosstabCell height="20" rowTotalGroup="name" columnTotalGroup="weekStartDate">
                        <cellContents mode="Opaque" style="Crosstab_CT"/>
                    </crosstabCell>
                    <crosstabCell width="90" height="20" rowTotalGroup="target">
                        <cellContents mode="Opaque" style="Crosstab_CG"/>
                    </crosstabCell>
                    <crosstabCell height="20" rowTotalGroup="target" columnTotalGroup="weekStartDate">
                        <cellContents mode="Opaque" style="Crosstab_CT"/>
                    </crosstabCell>
                    <crosstabCell width="90" height="20" rowTotalGroup="location">
                        <cellContents mode="Opaque" style="Crosstab_CG">
                            <textField>
                                <reportElement x="0" y="0" width="90" height="20" uuid="8c4215e9-f710-45ea-84a1-3a5c0adc6619"/>
                                <textFieldExpression><![CDATA[$V{totalspend_MEASURE}]]></textFieldExpression>
                            </textField>
                        </cellContents>
                    </crosstabCell>
                    <crosstabCell height="20" rowTotalGroup="location" columnTotalGroup="weekStartDate">
                        <cellContents mode="Opaque" style="Crosstab_CT"/>
                    </crosstabCell>
                </crosstab>
            </band>
        </detail>
    </jasperReport>