<?xml version="1.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="MondrianReport" pageWidth="595" pageHeight="842" columnWidth="515" columnSpacing="0" leftMargin="40" rightMargin="40" topMargin="50" bottomMargin="50">
	<style name="Sans_Normal" isDefault="true" fontName="DejaVu Sans" fontSize="8" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false"/>
	<style name="Sans_Bold" isDefault="false" fontName="DejaVu Sans" fontSize="8" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false"/>
	<queryString language="mdx">
		<![CDATA[select
				{[Measures].[Quantity], [Measures].[Unit Price]} ON columns,
				[Address].members on rows
				from [Sales]]]>
	</queryString>
	<field name="City" class="java.lang.String">
		<fieldDescription><![CDATA[Rows[Address][City]]]></fieldDescription>
	</field>
	<field name="Name" class="java.lang.String">
		<fieldDescription><![CDATA[Rows[Address][Person]]]></fieldDescription>
	</field>
	<field name="Street" class="java.lang.String">
		<fieldDescription><![CDATA[Rows[Address][Person](Person Address)]]></fieldDescription>
	</field>
	<field name="AddressMember" class="mondrian.olap.Member">
		<fieldDescription><![CDATA[Rows[Address]]]></fieldDescription>
	</field>
	<field name="Quantity" class="java.lang.Number">
		<fieldDescription><![CDATA[Data([Measures].[Quantity],?)]]></fieldDescription>
	</field>
	<field name="UnitPrice" class="java.lang.Number">
		<fieldDescription><![CDATA[Data([Measures].[Unit Price],?)]]></fieldDescription>
	</field>
	<field name="CityQuantity" class="java.lang.Number">
		<fieldDescription><![CDATA[Data(Rows[Address][City])([Measures].[Quantity],?)]]></fieldDescription>
	</field>
	<field name="CityUnitPrice" class="java.lang.Number">
		<fieldDescription><![CDATA[Data(Rows[Address][City])([Measures].[Unit Price],?)]]></fieldDescription>
	</field>
	<field name="TotalQuantity" class="java.lang.String">
		<fieldDescription><![CDATA[FormattedData(Rows[Address][(All)])([Measures].[Quantity],?)]]></fieldDescription>
	</field>
	<field name="TotalUnitPrice" class="java.lang.String">
		<fieldDescription><![CDATA[FormattedData(Rows[Address][(All)])([Measures].[Unit Price],?)]]></fieldDescription>
	</field>
	<group name="City">
		<groupExpression>$F{City}</groupExpression>
		<groupHeader>
			<band height="16">
				<textField evaluationTime="Group" evaluationGroup="City">
					<reportElement x="10" y="0" width="150" height="15" style="Sans_Bold"/>
					<textFieldExpression>$F{City}</textFieldExpression>
				</textField>
			</band>
		</groupHeader>
		<groupFooter>
			<band height="16">
			<frame>
				<reportElement x="0" y="0" width="515" height="15" mode="Opaque" backcolor="#E0E0E0"/>
				<box>
					<pen lineWidth="0.5"/>
				</box>
				<textField evaluationTime="Group" evaluationGroup="City">
					<reportElement x="10" y="0" width="150" height="15" style="Sans_Bold"/>
					<textElement verticalAlignment="Middle"/>
					<textFieldExpression>"City Totals: " + $F{City}</textFieldExpression>
				</textField>
				<textField pattern="#,###" evaluationTime="Group" evaluationGroup="City">
					<reportElement x="180" y="0" width="100" height="15" style="Sans_Bold"/>
					<textElement textAlignment="Right" verticalAlignment="Middle"/>
					<textFieldExpression class="java.lang.Number">$F{CityQuantity}</textFieldExpression>
				</textField>
				<textField pattern="$#,##0.00" evaluationTime="Group" evaluationGroup="City">
					<reportElement x="300" y="0" width="100" height="15" style="Sans_Bold"/>
					<textElement textAlignment="Right" verticalAlignment="Middle"/>
					<textFieldExpression class="java.lang.Number">$F{CityUnitPrice}</textFieldExpression>
				</textField>
			</frame>
			</band>
		</groupFooter>
	</group>
	<pageHeader>
		<band height="16">
			<frame>
				<reportElement x="0" y="0" width="515" height="15" mode="Opaque" backcolor="#E0E0E0"/>
				<box>
					<pen lineWidth="0.5"/>
				</box>
				<staticText>
					<reportElement x="20" y="0" width="150" height="15"/>
					<textElement verticalAlignment="Middle"/>
					<text>Address</text>
				</staticText>
				<staticText>
					<reportElement x="180" y="0" width="100" height="15"/>
					<textElement textAlignment="Right" verticalAlignment="Middle"/>
					<text>Quantity</text>
				</staticText>
				<staticText>
					<reportElement x="300" y="0" width="100" height="15"/>
					<textElement textAlignment="Right" verticalAlignment="Middle"/>
					<text>Average price</text>
				</staticText>
			</frame>
		</band>
	</pageHeader>
	<detail>
		<band height="32">
			<textField>
				<reportElement x="20" y="0" width="150" height="15"/>
				<textFieldExpression>$F{Name} + ", " + $F{Street}</textFieldExpression>
			</textField>
			<textField pattern="#,###">
				<reportElement x="180" y="0" width="100" height="15"/>
				<textElement textAlignment="Right"/>
				<textFieldExpression class="java.lang.Number">$F{Quantity}</textFieldExpression>
			</textField>
			<textField pattern="$#,##0.00">
				<reportElement x="300" y="0" width="100" height="15"/>
				<textElement textAlignment="Right"/>
				<textFieldExpression class="java.lang.Number">$F{UnitPrice}</textFieldExpression>
			</textField>
			<textField>
				<reportElement x="40" y="17" width="250" height="15"/>
				<textFieldExpression>$F{AddressMember}.toString()</textFieldExpression>
			</textField>
		</band>
	</detail>
	<summary>
		<band height="16">
			<frame>
				<reportElement x="0" y="0" width="515" height="15" mode="Opaque" backcolor="#E0E0E0"/>
				<box>
					<pen lineWidth="0.5"/>
				</box>
				<textField>
					<reportElement x="10" y="0" width="165" height="15" style="Sans_Bold"/>
					<textElement verticalAlignment="Middle"/>
					<textFieldExpression>"Grand Totals (formatted text from query result)"</textFieldExpression>
				</textField>
				<textField>
					<reportElement x="180" y="0" width="100" height="15" style="Sans_Bold"/>
					<textElement textAlignment="Right" verticalAlignment="Middle"/>
					<textFieldExpression>$F{TotalQuantity}</textFieldExpression>
				</textField>
				<textField>
					<reportElement x="300" y="0" width="100" height="15" style="Sans_Bold"/>
					<textElement textAlignment="Right" verticalAlignment="Middle"/>
					<textFieldExpression>$F{TotalUnitPrice}</textFieldExpression>
				</textField>
			</frame>
		</band>
	</summary>
</jasperReport>
