<?xml version="1.0" encoding="utf-8"?>
<Report Location="Microsoft Reporting Services" Host="bnbdatabase1" Path="Customers_Near_Stores_2008R2">
	<Group Name="Report Information">
		<Property Name="Description"><![CDATA[Purpose: Drillthrough report from store markers in Sales_by_Region_2008R2. Displays information about customers who live within the specified number of miles from a store. The store geolocation is a String parameter that contains a Well Known Text (WKT) value.]]></Property>
		<Property Name="Author"><![CDATA[Mary Lingel MSFT]]></Property>
		<Property Name="ReportID"><![CDATA[602b0e43-347c-4a5b-8326-d0c562c9ddcb]]></Property>
	</Group>
	<Group Name="Data Sources">
		<Group Name="AdventureWorks2008R2">
			<Property Name="Name"><![CDATA[AdventureWorks2008R2]]></Property>
			<Property Name="Security Type"><![CDATA[None]]></Property>
		</Group>
	</Group>
	<Group Name="Datasets">
		<Group Name="CustomerLocations">
			<Property Name="Name"><![CDATA[CustomerLocations]]></Property>
			<Group Name="Query">
				<Property Name="Data Source"><![CDATA[AdventureWorks2008R2]]></Property>
				<Property Name="CommandText"><![CDATA[SELECT        c.CustomerID, c.PersonID AS BusinessEntityID, p.FirstName AS Name1, p.LastName AS Name2, ea.EmailAddress, ad.City, ad.PostalCode, 
                         sp.Name AS StateProvince, sp.StateProvinceCode, ad.SpatialLocation.STDistance(@GeoLocation) / 1609.344 AS DistanceinMiles, ad.SpatialLocation, 
                         p.Demographics.value('declare namespace awns="http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/IndividualSurvey"; (awns:IndividualSurvey/awns:NumberCarsOwned) [1]',
                          'int') AS NumberCarsOwned, 
                         p.Demographics.value('declare namespace awns="http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/IndividualSurvey"; (awns:IndividualSurvey/awns:CommuteDistance) [1]',
                          'varchar(30)') AS CommuteDistance
FROM            Sales.Customer AS c INNER JOIN
                         Person.Person AS p ON p.BusinessEntityID = c.PersonID INNER JOIN
                         Person.BusinessEntityAddress AS a ON a.BusinessEntityID = p.BusinessEntityID INNER JOIN
                         Person.AddressType AS t ON a.AddressTypeID = t.AddressTypeID INNER JOIN
                         Person.Address AS ad ON ad.AddressID = a.AddressID INNER JOIN
                         Person.EmailAddress AS ea ON ea.BusinessEntityID = p.BusinessEntityID INNER JOIN
                         Person.StateProvince AS sp ON sp.StateProvinceID = ad.StateProvinceID
WHERE        (c.StoreID IS NULL) AND (t.Name = N'Home') AND (sp.CountryRegionCode = N'US') AND (ad.SpatialLocation.STDistance(@GeoLocation) / 1609.344 < @Radius)]]></Property>
				<Group Name="Parameters">
					<Property Name="@GeoLocation"><![CDATA[=Parameters!GeoLocation.Value]]></Property>
					<Property Name="@Radius"><![CDATA[=Parameters!Radius.Value]]></Property>
				</Group>
			</Group>
			<Group Name="Fields">
				<Group Name="CustomerID">
					<Property Name="Name"><![CDATA[CustomerID]]></Property>
					<Property Name="Source"><![CDATA[CustomerID]]></Property>
					<Property Name="Data Type"><![CDATA[Int32]]></Property>
				</Group>
				<Group Name="BusinessEntityID">
					<Property Name="Name"><![CDATA[BusinessEntityID]]></Property>
					<Property Name="Source"><![CDATA[BusinessEntityID]]></Property>
					<Property Name="Data Type"><![CDATA[Int32]]></Property>
				</Group>
				<Group Name="Name1">
					<Property Name="Name"><![CDATA[Name1]]></Property>
					<Property Name="Source"><![CDATA[Name1]]></Property>
					<Property Name="Data Type"><![CDATA[String]]></Property>
				</Group>
				<Group Name="Name2">
					<Property Name="Name"><![CDATA[Name2]]></Property>
					<Property Name="Source"><![CDATA[Name2]]></Property>
					<Property Name="Data Type"><![CDATA[String]]></Property>
				</Group>
				<Group Name="EmailAddress">
					<Property Name="Name"><![CDATA[EmailAddress]]></Property>
					<Property Name="Source"><![CDATA[EmailAddress]]></Property>
					<Property Name="Data Type"><![CDATA[String]]></Property>
				</Group>
				<Group Name="City">
					<Property Name="Name"><![CDATA[City]]></Property>
					<Property Name="Source"><![CDATA[City]]></Property>
					<Property Name="Data Type"><![CDATA[String]]></Property>
				</Group>
				<Group Name="PostalCode">
					<Property Name="Name"><![CDATA[PostalCode]]></Property>
					<Property Name="Source"><![CDATA[PostalCode]]></Property>
					<Property Name="Data Type"><![CDATA[String]]></Property>
				</Group>
				<Group Name="StateProvince">
					<Property Name="Name"><![CDATA[StateProvince]]></Property>
					<Property Name="Source"><![CDATA[StateProvince]]></Property>
					<Property Name="Data Type"><![CDATA[String]]></Property>
				</Group>
				<Group Name="StateProvinceCode">
					<Property Name="Name"><![CDATA[StateProvinceCode]]></Property>
					<Property Name="Source"><![CDATA[StateProvinceCode]]></Property>
					<Property Name="Data Type"><![CDATA[String]]></Property>
				</Group>
				<Group Name="DistanceinMiles">
					<Property Name="Name"><![CDATA[DistanceinMiles]]></Property>
					<Property Name="Source"><![CDATA[DistanceinMiles]]></Property>
					<Property Name="Data Type"><![CDATA[Double]]></Property>
				</Group>
				<Group Name="SpatialLocation">
					<Property Name="Name"><![CDATA[SpatialLocation]]></Property>
					<Property Name="Source"><![CDATA[SpatialLocation]]></Property>
					<Property Name="Data Type"><![CDATA[Microsoft.SqlServer.Types.SqlGeography]]></Property>
				</Group>
				<Group Name="NumberCarsOwned">
					<Property Name="Name"><![CDATA[NumberCarsOwned]]></Property>
					<Property Name="Source"><![CDATA[NumberCarsOwned]]></Property>
					<Property Name="Data Type"><![CDATA[Int32]]></Property>
				</Group>
				<Group Name="CommuteDistance">
					<Property Name="Name"><![CDATA[CommuteDistance]]></Property>
					<Property Name="Source"><![CDATA[CommuteDistance]]></Property>
					<Property Name="Data Type"><![CDATA[String]]></Property>
				</Group>
			</Group>
		</Group>
		<Group Name="StoreLocation">
			<Property Name="Name"><![CDATA[StoreLocation]]></Property>
			<Group Name="Query">
				<Property Name="Data Source"><![CDATA[AdventureWorks2008R2]]></Property>
				<Property Name="CommandText"><![CDATA[SELECT  
    [StoreID] as BusinessEntityID
    , s.Name as Store
   -- , t.Name as AddressType -- Main Office or Shipping
   , ad.PostalCode
   -- , sp.CountryRegionCode
   --, sp.Name as StateProvince
   --, sp.StateProvinceCode
   , ad.SpatialLocation.ToString() as GeoLocation
  FROM [Sales].[Customer] c
    INNER JOIN Sales.Store s ON s.BusinessEntityID = c.StoreID
    INNER JOIN Person.BusinessEntityAddress a ON a.BusinessEntityID = s.BusinessEntityID
    INNER JOIN Person.AddressType t ON a.AddressTypeID=t.AddressTypeID
    INNER JOIN Person.[Address] ad ON ad.AddressID = a.AddressID 
    INNER JOIN Person.StateProvince sp ON sp.StateProvinceID = ad.StateProvinceID
 WHERE  -- PersonID IS NULL means Customer is a store
   PersonID IS NULL 
   AND t.Name = N'Main Office' 
   AND sp.CountryRegionCode = N'US'
]]></Property>
				<Group Name="Parameters" />
			</Group>
			<Group Name="Fields">
				<Group Name="BusinessEntityID">
					<Property Name="Name"><![CDATA[BusinessEntityID]]></Property>
					<Property Name="Source"><![CDATA[BusinessEntityID]]></Property>
					<Property Name="Data Type"><![CDATA[Int32]]></Property>
				</Group>
				<Group Name="Store">
					<Property Name="Name"><![CDATA[Store]]></Property>
					<Property Name="Source"><![CDATA[Store]]></Property>
					<Property Name="Data Type"><![CDATA[String]]></Property>
				</Group>
				<Group Name="PostalCode">
					<Property Name="Name"><![CDATA[PostalCode]]></Property>
					<Property Name="Source"><![CDATA[PostalCode]]></Property>
					<Property Name="Data Type"><![CDATA[String]]></Property>
				</Group>
				<Group Name="GeoLocation">
					<Property Name="Name"><![CDATA[GeoLocation]]></Property>
					<Property Name="Source"><![CDATA[GeoLocation]]></Property>
					<Property Name="Data Type"><![CDATA[String]]></Property>
				</Group>
			</Group>
		</Group>
	</Group>
	<Group Name="Parameters">
		<Group Name="GeoLocation">
			<Property Name="Name"><![CDATA[GeoLocation]]></Property>
			<Property Name="Data Type"><![CDATA[String]]></Property>
			<Property Name="Prompt"><![CDATA[Store location?]]></Property>
			<Group Name="Default Value">
				<Group Name="Dataset Reference" />
				<Property Name="Values"><![CDATA[POINT (-82.4151596338717 40.7459610884615)
]]></Property>
			</Group>
			<Group Name="Valid Value">
				<Group Name="Dataset Reference">
					<Property Name="Dataset Name"><![CDATA[StoreLocation]]></Property>
					<Property Name="Label"><![CDATA[Store]]></Property>
					<Property Name="Value"><![CDATA[GeoLocation]]></Property>
				</Group>
			</Group>
		</Group>
		<Group Name="Radius">
			<Property Name="Name"><![CDATA[Radius]]></Property>
			<Property Name="Data Type"><![CDATA[Integer]]></Property>
			<Property Name="Prompt"><![CDATA[Distance in miles?]]></Property>
			<Group Name="Default Value">
				<Group Name="Dataset Reference" />
				<Property Name="Values"><![CDATA[100
]]></Property>
			</Group>
			<Group Name="Valid Value">
				<Group Name="Dataset Reference" />
			</Group>
		</Group>
		<Group Name="ShowAll">
			<Property Name="Name"><![CDATA[ShowAll]]></Property>
			<Property Name="Data Type"><![CDATA[Boolean]]></Property>
			<Property Name="Prompt"><![CDATA[Show all information?]]></Property>
			<Group Name="Default Value">
				<Group Name="Dataset Reference" />
				<Property Name="Values"><![CDATA[false
]]></Property>
			</Group>
			<Group Name="Valid Value">
				<Group Name="Dataset Reference" />
			</Group>
		</Group>
	</Group>
	<Group Name="Embedded Images">
		<Group Name="AdventureWorksLogo">
			<Property Name="Name"><![CDATA[AdventureWorksLogo]]></Property>
			<Property Name="Type"><![CDATA[jpeg]]></Property>
		</Group>
	</Group>
	<Group Name="Page Header">
		<Group Name="Report Items">
			<Group Name="Logo">
				<Property Name="Name"><![CDATA[Logo]]></Property>
				<Property Name="Type"><![CDATA[Image]]></Property>
				<Property Name="Source Type"><![CDATA[Embedded Image Name]]></Property>
				<Property Name="Embedded Image Name"><![CDATA[AdventureWorksLogo]]></Property>
			</Group>
			<Group Name="ReportName">
				<Property Name="Name"><![CDATA[ReportName]]></Property>
				<Property Name="Type"><![CDATA[Text Box]]></Property>
				<Property Name="Content"><![CDATA[=Globals!ReportName]]></Property>
			</Group>
			<Group Name="tbBackInstructions">
				<Property Name="Name"><![CDATA[tbBackInstructions]]></Property>
				<Property Name="Type"><![CDATA[Text Box]]></Property>
				<Property Name="Content"><![CDATA[To return to the main report, use the browser Back button.]]></Property>
			</Group>
			<Group Name="tbTitle">
				<Property Name="Name"><![CDATA[tbTitle]]></Property>
				<Property Name="Type"><![CDATA[Text Box]]></Property>
				<Property Name="Content"><![CDATA[Demographics for the =CountDistinct(Fields!CustomerID.Value,"CustomerLocations") =IIF(CountDistinct(Fields!CustomerID.Value,"CustomerLocations")=1,"Customer","Customers")
living within =Parameters!Radius.Value miles of the store
=Parameters!GeoLocation.Label

Grouped by Commute Distance]]></Property>
			</Group>
		</Group>
	</Group>
	<Group Name="Body">
		<Group Name="Report Items">
			<Group Name="Textbox3">
				<Property Name="Name"><![CDATA[Textbox3]]></Property>
				<Property Name="Type"><![CDATA[Text Box]]></Property>
				<Property Name="Content"><![CDATA[Name]]></Property>
			</Group>
			<Group Name="Textbox5">
				<Property Name="Name"><![CDATA[Textbox5]]></Property>
				<Property Name="Type"><![CDATA[Text Box]]></Property>
				<Property Name="Content"><![CDATA[Distancein Miles]]></Property>
			</Group>
			<Group Name="Textbox7">
				<Property Name="Name"><![CDATA[Textbox7]]></Property>
				<Property Name="Type"><![CDATA[Text Box]]></Property>
				<Property Name="Content"><![CDATA[Number Cars Owned]]></Property>
			</Group>
			<Group Name="Textbox11">
				<Property Name="Name"><![CDATA[Textbox11]]></Property>
				<Property Name="Type"><![CDATA[Text Box]]></Property>
				<Property Name="Content"><![CDATA[Email Address]]></Property>
			</Group>
			<Group Name="Name2">
				<Property Name="Name"><![CDATA[Name2]]></Property>
				<Property Name="Type"><![CDATA[Text Box]]></Property>
				<Property Name="Content"><![CDATA[=Fields!Name2.Value, =Fields!Name1.Value]]></Property>
			</Group>
			<Group Name="DistanceinMiles">
				<Property Name="Name"><![CDATA[DistanceinMiles]]></Property>
				<Property Name="Type"><![CDATA[Text Box]]></Property>
				<Property Name="Content"><![CDATA[=Fields!DistanceinMiles.Value]]></Property>
			</Group>
			<Group Name="NumberCarsOwned">
				<Property Name="Name"><![CDATA[NumberCarsOwned]]></Property>
				<Property Name="Type"><![CDATA[Text Box]]></Property>
				<Property Name="Content"><![CDATA[=Fields!NumberCarsOwned.Value]]></Property>
			</Group>
			<Group Name="EmailAddress">
				<Property Name="Name"><![CDATA[EmailAddress]]></Property>
				<Property Name="Type"><![CDATA[Text Box]]></Property>
				<Property Name="Content"><![CDATA[=Fields!EmailAddress.Value]]></Property>
			</Group>
			<Group Name="Textbox13">
				<Property Name="Name"><![CDATA[Textbox13]]></Property>
				<Property Name="Type"><![CDATA[Text Box]]></Property>
				<Property Name="Content"><![CDATA[Commute Distance]]></Property>
			</Group>
			<Group Name="CommuteDistance">
				<Property Name="Name"><![CDATA[CommuteDistance]]></Property>
				<Property Name="Type"><![CDATA[Text Box]]></Property>
				<Property Name="Content"><![CDATA[=Fields!CommuteDistance.Value]]></Property>
			</Group>
		</Group>
		<Group Name="Data Regions">
			<Group Name="tblxTable_Demographics">
				<Property Name="Name"><![CDATA[tblxTable_Demographics]]></Property>
				<Property Name="Type"><![CDATA[Table]]></Property>
				<Group Name="Row Member 1" />
				<Group Name="Row Member 2">
					<Group Name="CommuteDistance">
						<Property Name="Name"><![CDATA[CommuteDistance]]></Property>
						<Property Name="Expressions"><![CDATA[=Fields!CommuteDistance.Value]]></Property>
					</Group>
					<Property Name="Sort Expressions"><![CDATA[=Fields!CommuteDistance.Value]]></Property>
				</Group>
				<Group Name="Row Member 2">
					<Group Name="Details">
						<Property Name="Name"><![CDATA[Details]]></Property>
					</Group>
				</Group>
				<Property Name="Source Dataset"><![CDATA[CustomerLocations]]></Property>
			</Group>
		</Group>
	</Group>
	<Group Name="Page Footer">
		<Group Name="Report Items">
			<Group Name="tbDescription">
				<Property Name="Name"><![CDATA[tbDescription]]></Property>
				<Property Name="Type"><![CDATA[Text Box]]></Property>
				<Property Name="Content"><![CDATA[Purpose: Drillthrough report from store markers in Sales_by_Region_2008R2. Displays information about customers who live within the specified number of miles from a store. The store geolocation is a String parameter that contains a Well Known Text (WKT) value.]]></Property>
				<Group Name="Visibility">
					<Property Name="Show or hide based on expression"><![CDATA[=NOT Parameters!ShowAll.Value]]></Property>
				</Group>
			</Group>
		</Group>
	</Group>
</Report>