<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Chris Bushnell</title>
	<atom:link href="http://cbushnell.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://cbushnell.wordpress.com</link>
	<description>Tips from a Sitecore technical writer</description>
	<lastBuildDate>Fri, 20 Nov 2009 14:31:43 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='cbushnell.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/16e4db880983ecc072811e31f2eba05b?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Chris Bushnell</title>
		<link>http://cbushnell.wordpress.com</link>
	</image>
			<item>
		<title>Creating a Top Records Filter in Sitecore OMS</title>
		<link>http://cbushnell.wordpress.com/2009/11/02/creating-a-top-records-filter-in-sitecore-oms-3/</link>
		<comments>http://cbushnell.wordpress.com/2009/11/02/creating-a-top-records-filter-in-sitecore-oms-3/#comments</comments>
		<pubDate>Mon, 02 Nov 2009 13:16:39 +0000</pubDate>
		<dc:creator>cbushnell</dc:creator>
				<category><![CDATA[Sitecore OMS reports]]></category>

		<guid isPermaLink="false">http://cbushnell.wordpress.com/?p=396</guid>
		<description><![CDATA[Step 5: Test the Top Filter<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cbushnell.wordpress.com&blog=9791478&post=396&subd=cbushnell&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><h4>Step 5: Test the Top Filter</h4>
<p>View the <em>ProfileKeyFilterTop</em> report and test your new top filter in Sitecore Analytics.</p>
<p>1. In Sitecore Analytics, to refresh your reports, close and then expand the Reports node.</p>
<p>2. Click on your new report: <em>ProfileKeyFilterTop</em></p>
<p>3. Select a profile key such as <em>Semi-pro</em> using the filter created in my previous blog. All records for the chosen profile key are displayed in your report.</p>
<p><a href="http://cbushnell.files.wordpress.com/2009/11/filtersemipro.png"><img style="display:inline;border:0;" title="Filter-Semi-pro" src="http://cbushnell.files.wordpress.com/2009/11/filtersemipro_thumb.png?w=508&#038;h=500" border="0" alt="Filter-Semi-pro" width="508" height="500" /></a></p>
<p>4. Open the <strong>Filters Editor</strong> window again. You should see your new top filter displayed in the <strong>Filters Editor</strong> window.</p>
<p>5. Select your top records filter.</p>
<p><a href="http://cbushnell.files.wordpress.com/2009/11/topfilter.png"><img style="display:inline;border:0;" title="top filter" src="http://cbushnell.files.wordpress.com/2009/11/topfilter_thumb.png?w=233&#038;h=352" border="0" alt="top filter" width="233" height="352" /></a></p>
<p>6. Click <em>value</em> in the <strong>Filter description</strong> panel and enter a value such as <em>5</em>. Click <strong>OK</strong> to close the <strong>Filters Editor</strong> window. You should now only see the top 5 records returned for the <em>Semi-pro</em> profile key.</p>
<p><a href="http://cbushnell.files.wordpress.com/2009/11/semiprotop5.png"><img style="display:inline;border:0;" title="semi-pro top 5" src="http://cbushnell.files.wordpress.com/2009/11/semiprotop5_thumb.png?w=493&#038;h=377" border="0" alt="semi-pro top 5" width="493" height="377" /></a></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cbushnell.wordpress.com/396/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cbushnell.wordpress.com/396/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cbushnell.wordpress.com/396/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cbushnell.wordpress.com/396/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cbushnell.wordpress.com/396/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cbushnell.wordpress.com/396/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cbushnell.wordpress.com/396/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cbushnell.wordpress.com/396/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cbushnell.wordpress.com/396/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cbushnell.wordpress.com/396/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cbushnell.wordpress.com&blog=9791478&post=396&subd=cbushnell&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://cbushnell.wordpress.com/2009/11/02/creating-a-top-records-filter-in-sitecore-oms-3/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c5c6495ef08d15440e64b4ec73673844?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cbushnell</media:title>
		</media:content>

		<media:content url="http://cbushnell.files.wordpress.com/2009/11/filtersemipro_thumb.png" medium="image">
			<media:title type="html">Filter-Semi-pro</media:title>
		</media:content>

		<media:content url="http://cbushnell.files.wordpress.com/2009/11/topfilter_thumb.png" medium="image">
			<media:title type="html">top filter</media:title>
		</media:content>

		<media:content url="http://cbushnell.files.wordpress.com/2009/11/semiprotop5_thumb.png" medium="image">
			<media:title type="html">semi-pro top 5</media:title>
		</media:content>
	</item>
		<item>
		<title>Creating a Top Records Filter in Sitecore OMS</title>
		<link>http://cbushnell.wordpress.com/2009/11/02/creating-a-top-records-filter-in-sitecore-oms-2/</link>
		<comments>http://cbushnell.wordpress.com/2009/11/02/creating-a-top-records-filter-in-sitecore-oms-2/#comments</comments>
		<pubDate>Mon, 02 Nov 2009 13:11:19 +0000</pubDate>
		<dc:creator>cbushnell</dc:creator>
				<category><![CDATA[Sitecore OMS reports]]></category>

		<guid isPermaLink="false">http://cbushnell.wordpress.com/?p=389</guid>
		<description><![CDATA[Step 4: Configure your Sitecore Filter Definition Item<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cbushnell.wordpress.com&blog=9791478&post=389&subd=cbushnell&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><h4>Step 4: Configure your Sitecore Filter Definition Item</h4>
<p>When you have created your filter class and updated your SQL query you then configure your Sitecore filter definition item to point to your C# assembly.</p>
<p>1. In the Content Editor, Criteria folder, select your filter definition item.</p>
<p><em>/sitecore/system/Settings/Analytics/Filters/Criteria/WhereTopRecords</em></p>
<p><a href="http://cbushnell.files.wordpress.com/2009/11/toprecordscriteriaitem.png"><img style="display:inline;border-width:0;" title="top records criteria item" src="http://cbushnell.files.wordpress.com/2009/11/toprecordscriteriaitem_thumb.png?w=414&#038;h=193" border="0" alt="top records criteria item" width="414" height="193" /></a></p>
<p>2. In the <strong>Type</strong> field, enter the correct path to your C# class and assembly.</p>
<p>ChrisTest.sitecore_modules.Cbtest.WhereTopRecords,ChrisTest</p>
<p>namespace                                     class name           assembly</p>
<p>3. Save your changes.</p>
<p>My next post: Step 5 &#8211; <a href="http://cbushnell.wordpress.com/2009/11/02/creating-a-top-records-filter-in-sitecore-oms-3/">Test the Top Filter</a></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cbushnell.wordpress.com/389/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cbushnell.wordpress.com/389/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cbushnell.wordpress.com/389/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cbushnell.wordpress.com/389/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cbushnell.wordpress.com/389/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cbushnell.wordpress.com/389/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cbushnell.wordpress.com/389/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cbushnell.wordpress.com/389/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cbushnell.wordpress.com/389/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cbushnell.wordpress.com/389/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cbushnell.wordpress.com&blog=9791478&post=389&subd=cbushnell&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://cbushnell.wordpress.com/2009/11/02/creating-a-top-records-filter-in-sitecore-oms-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c5c6495ef08d15440e64b4ec73673844?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cbushnell</media:title>
		</media:content>

		<media:content url="http://cbushnell.files.wordpress.com/2009/11/toprecordscriteriaitem_thumb.png" medium="image">
			<media:title type="html">top records criteria item</media:title>
		</media:content>
	</item>
		<item>
		<title>Creating a Top Records Filter in Sitecore OMS</title>
		<link>http://cbushnell.wordpress.com/2009/11/02/creating-a-top-records-filter-in-sitecore-oms/</link>
		<comments>http://cbushnell.wordpress.com/2009/11/02/creating-a-top-records-filter-in-sitecore-oms/#comments</comments>
		<pubDate>Mon, 02 Nov 2009 12:55:11 +0000</pubDate>
		<dc:creator>cbushnell</dc:creator>
				<category><![CDATA[Sitecore OMS reports]]></category>

		<guid isPermaLink="false">http://cbushnell.wordpress.com/?p=386</guid>
		<description><![CDATA[Step 3: Add a TOP Clause to your SQL Query<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cbushnell.wordpress.com&blog=9791478&post=386&subd=cbushnell&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><h4>Step 3: Add a TOP Clause to your SQL Query</h4>
<p>To add a filter implementation to a report, you normally add a placeholder to the WHERE clause in your SQL query. However, since the TOP clause appears immediately after the SELECT clause, you need a workaround to implement a Top filter. Use Transact SQL (TSQL) to create a CASE WHEN ELSE statement and embed this into the SELECT clause of your SQL query.</p>
<p>To add a TOP clause to your SQL query.</p>
<p>1. Open your <em>ProfileKeyFilterTop</em> report in the report designer</p>
<p>2. Right click the <em>IPOwners</em> data source and click Edit</p>
<p>3. Copy the following TSQL code into your SQL query directly after the SELECT statement.</p>
<div id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:41e3f8b9-fec1-4c8b-9a99-2901561d45c0" class="wlWriterEditableSmartContent" style="display:inline;float:none;margin:0;padding:0;">
<pre style="background-color:#ffffff;white-space:pre-wrap;overflow:auto;"><span style="color:#0000ff;">top</span><span style="color:#000000;"> (
  </span><span style="color:#ff00ff;">CASE</span><span style="color:#000000;"> </span><span style="color:#0000ff;">WHEN</span><span style="color:#000000;"> </span><span style="color:#ff0000;">'</span><span style="color:#ff0000;">{MaxRecords}</span><span style="color:#ff0000;">'</span><span style="color:#000000;"> </span><span style="color:#808080;">=</span><span style="color:#000000;"> </span><span style="color:#ff0000;">''</span><span style="color:#000000;">
                  </span><span style="color:#0000ff;">THEN</span><span style="color:#000000;"> </span><span style="color:#800000;font-weight:bold;">1000</span><span style="color:#000000;">
                  </span><span style="color:#0000ff;">ELSE</span><span style="color:#000000;"> </span><span style="color:#ff00ff;">CAST</span><span style="color:#000000;">(</span><span style="color:#ff00ff;">REPLACE</span><span style="color:#000000;">( </span><span style="color:#ff00ff;">REPLACE</span><span style="color:#000000;">( </span><span style="color:#ff0000;">'</span><span style="color:#ff0000;">{MaxRecords}</span><span style="color:#ff0000;">'</span><span style="color:#000000;">, </span><span style="color:#ff0000;">'</span><span style="color:#ff0000;">and (</span><span style="color:#ff0000;">'</span><span style="color:#000000;">, </span><span style="color:#ff0000;">''</span><span style="color:#000000;"> ), </span><span style="color:#ff0000;">'</span><span style="color:#ff0000;">)</span><span style="color:#ff0000;">'</span><span style="color:#000000;">, </span><span style="color:#ff0000;">''</span><span style="color:#000000;">) </span><span style="color:#0000ff;">as</span><span style="color:#000000;"> </span><span style="color:#0000ff;">integer</span><span style="color:#000000;"> )
                  </span><span style="color:#0000ff;">END</span><span style="color:#000000;">
              )
</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></p>
<p>Notice that the placeholder {MaxRecords} is included as part of this embedded code.</p>
<p><strong>The Workaround</strong></p>
<p>Our placeholder {MaxRecords} contains the three parameters added by the <em>AddWhereClause</em> method call (described in step 2). Our workaround allows us to insert this clause into the SELECT statement at the top of the SQL query even though this is not actually part of the WHERE clause. However, this will only work if we remove some of the unnecessary parameters and characters generated by the <em>AddWhereClause</em> method, because the AddWhereClause method generates text that looks something like:</p>
<p>and (10)</p>
<p>where “10” is the user entered value, but the TOP clause just requires:</p>
<p>10</p>
<p>The code in the parentheses following the TOP statement contains a TSQL CASE WHEN statement. In Transact SQL this can be used instead of the classic IF THEN statement. We use it here to add one of two alternative numerical values to the TOP clause:</p>
<p>· A default value of 1000 (stated in the THEN clause)</p>
<p>OR</p>
<p>· A user entered value (stated in the ELSE clause)</p>
<p>If an end-user fails to enter a value, then the first 1000 records are displayed by default. The ELSE part of the code takes the text generated by the <em>AddWhereClause</em> method, strips out unwanted code generated by the <em>AddWhereClause</em> method using REPLACE, and converts the remaining user entered value to an integer using CAST.</p>
<div id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:8d2e1015-b188-4b61-9558-c2201052ec23" class="wlWriterEditableSmartContent" style="display:inline;float:none;margin:0;padding:0;">
<pre style="background-color:#ffffff;white-space:pre-wrap;overflow:auto;"><span style="color:#ff00ff;">CAST</span><span style="color:#000000;">(</span><span style="color:#ff00ff;">REPLACE</span><span style="color:#000000;">( </span><span style="color:#ff00ff;">REPLACE</span><span style="color:#000000;">( </span><span style="color:#ff0000;">'</span><span style="color:#ff0000;">{MaxRecords}</span><span style="color:#ff0000;">'</span><span style="color:#000000;">, </span><span style="color:#ff0000;">'</span><span style="color:#ff0000;">and (</span><span style="color:#ff0000;">'</span><span style="color:#000000;">, </span><span style="color:#ff0000;">''</span><span style="color:#000000;"> ), </span><span style="color:#ff0000;">'</span><span style="color:#ff0000;">)</span><span style="color:#ff0000;">'</span><span style="color:#000000;">, </span><span style="color:#ff0000;">''</span><span style="color:#000000;">) </span><span style="color:#0000ff;">as</span><span style="color:#000000;"> </span><span style="color:#0000ff;">integer</span><span style="color:#000000;"> )</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></p>
<p>So if a user enters a value such as “10” then <em>TOP 10</em> is inserted into the SELECT part of the SQL query.</p>
<p>4. Next, create a report designer variable for your placeholder {MaxRecords}. To do this, in the <strong>Dictionary</strong> panel, click <em>New Item</em>, <em>New Variable</em>.</p>
<p>5. In the <strong>Name</strong> field enter <em>MaxRecords </em>and enter the same value in the <strong>Alias </strong>field. Keep the Type as string and click OK.</p>
<p><a href="http://cbushnell.files.wordpress.com/2009/11/maxrecordsvariable.png"><img style="display:inline;border:0;" title="MaxRecords variable" src="http://cbushnell.files.wordpress.com/2009/11/maxrecordsvariable_thumb.png?w=244&#038;h=210" border="0" alt="MaxRecords variable" width="244" height="210" /></a></p>
<p>Make sure your full SQL query matches the code below:</p>
<div id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:4705e4f5-bf1a-4a82-9838-9b71b63ea663" class="wlWriterEditableSmartContent" style="display:inline;float:none;margin:0;padding:0;">
<pre style="background-color:#ffffff;white-space:pre-wrap;overflow:auto;"><span style="color:#0000ff;">SELECT</span><span style="color:#000000;">
  </span><span style="color:#0000ff;">top</span><span style="color:#000000;"> (
  </span><span style="color:#ff00ff;">CASE</span><span style="color:#000000;"> </span><span style="color:#0000ff;">WHEN</span><span style="color:#000000;"> </span><span style="color:#ff0000;">'</span><span style="color:#ff0000;">{MaxRecords}</span><span style="color:#ff0000;">'</span><span style="color:#000000;"> </span><span style="color:#808080;">=</span><span style="color:#000000;"> </span><span style="color:#ff0000;">''</span><span style="color:#000000;">
                  </span><span style="color:#0000ff;">THEN</span><span style="color:#000000;"> </span><span style="color:#800000;font-weight:bold;">1000</span><span style="color:#000000;">
                  </span><span style="color:#0000ff;">ELSE</span><span style="color:#000000;"> </span><span style="color:#ff00ff;">CAST</span><span style="color:#000000;">(</span><span style="color:#ff00ff;">REPLACE</span><span style="color:#000000;">( </span><span style="color:#ff00ff;">REPLACE</span><span style="color:#000000;">( </span><span style="color:#ff0000;">'</span><span style="color:#ff0000;">{MaxRecords}</span><span style="color:#ff0000;">'</span><span style="color:#000000;">, </span><span style="color:#ff0000;">'</span><span style="color:#ff0000;">and (</span><span style="color:#ff0000;">'</span><span style="color:#000000;">, </span><span style="color:#ff0000;">''</span><span style="color:#000000;"> ), </span><span style="color:#ff0000;">'</span><span style="color:#ff0000;">)</span><span style="color:#ff0000;">'</span><span style="color:#000000;">, </span><span style="color:#ff0000;">''</span><span style="color:#000000;">) </span><span style="color:#0000ff;">as</span><span style="color:#000000;"> </span><span style="color:#0000ff;">integer</span><span style="color:#000000;"> )
                  </span><span style="color:#0000ff;">END</span><span style="color:#000000;">
              )
</span><span style="color:#ff00ff;">Count</span><span style="color:#000000;">(</span><span style="color:#0000ff;">DISTINCT</span><span style="color:#000000;"> IpOwner.IPOwnerId) </span><span style="color:#0000ff;">AS</span><span style="color:#000000;"> IPOwnerIdObject, IpOwner.Name,  IpOwner.Country,
</span><span style="color:#ff00ff;">Count</span><span style="color:#000000;">(</span><span style="color:#0000ff;">DISTINCT</span><span style="color:#000000;"> Session.GlobalSessionId) </span><span style="color:#0000ff;">AS</span><span style="color:#000000;"> VisitorCount,
</span><span style="color:#ff00ff;">Count</span><span style="color:#000000;">(</span><span style="color:#0000ff;">DISTINCT</span><span style="color:#000000;"> Session.SessionId) </span><span style="color:#0000ff;">AS</span><span style="color:#000000;"> VisitCount,
</span><span style="color:#ff00ff;">Sum</span><span style="color:#000000;">(</span><span style="color:#0000ff;">DISTINCT</span><span style="color:#000000;"> ProfileKey.Value) </span><span style="color:#0000ff;">AS</span><span style="color:#000000;"> Score,
ProfileKeyDefinition.Name </span><span style="color:#0000ff;">AS</span><span style="color:#000000;"> Prof

</span><span style="color:#0000ff;">FROM</span><span style="color:#000000;"> Session
</span><span style="color:#0000ff;">INNER</span><span style="color:#000000;"> </span><span style="color:#808080;">JOIN</span><span style="color:#000000;">  Profile </span><span style="color:#0000ff;">ON</span><span style="color:#000000;"> Session.SessionId </span><span style="color:#808080;">=</span><span style="color:#000000;"> Profile.SessionId
</span><span style="color:#0000ff;">INNER</span><span style="color:#000000;"> </span><span style="color:#808080;">JOIN</span><span style="color:#000000;">  GlobalSession </span><span style="color:#0000ff;">ON</span><span style="color:#000000;"> GlobalSession.GlobalSessionId </span><span style="color:#808080;">=</span><span style="color:#000000;"> Session.GlobalSessionId
</span><span style="color:#0000ff;">INNER</span><span style="color:#000000;"> </span><span style="color:#808080;">JOIN</span><span style="color:#000000;">  Ip </span><span style="color:#0000ff;">ON</span><span style="color:#000000;"> Ip.IpId </span><span style="color:#808080;">=</span><span style="color:#000000;"> Session.IpId
</span><span style="color:#0000ff;">INNER</span><span style="color:#000000;"> </span><span style="color:#808080;">JOIN</span><span style="color:#000000;">  IpOwner </span><span style="color:#0000ff;">ON</span><span style="color:#000000;"> IpOwner.IpOwnerId </span><span style="color:#808080;">=</span><span style="color:#000000;"> Ip.IpOwnerId
</span><span style="color:#0000ff;">INNER</span><span style="color:#000000;"> </span><span style="color:#808080;">JOIN</span><span style="color:#000000;">  Browser </span><span style="color:#0000ff;">ON</span><span style="color:#000000;"> Browser.BrowserId </span><span style="color:#808080;">=</span><span style="color:#000000;"> Session.BrowserId
</span><span style="color:#0000ff;">INNER</span><span style="color:#000000;"> </span><span style="color:#808080;">JOIN</span><span style="color:#000000;">  ProfileKey </span><span style="color:#0000ff;">ON</span><span style="color:#000000;"> ProfileKey.ProfileId </span><span style="color:#808080;">=</span><span style="color:#000000;"> Profile.ProfileId
</span><span style="color:#0000ff;">INNER</span><span style="color:#000000;"> </span><span style="color:#808080;">JOIN</span><span style="color:#000000;">  ProfileKeyDefinition </span><span style="color:#0000ff;">ON</span><span style="color:#000000;"> ProfileKeyDefinition.ProfileKeyDefinitionId </span><span style="color:#808080;">=</span><span style="color:#000000;">  ProfileKey.ProfileKeyDefinitionId 

</span><span style="color:#0000ff;">WHERE</span><span style="color:#000000;">
Session.</span><span style="color:#0000ff;">Timestamp</span><span style="color:#000000;"> </span><span style="color:#808080;">&gt;=</span><span style="color:#000000;"> </span><span style="color:#008000;">@StartDate</span><span style="color:#000000;"> </span><span style="color:#808080;">and</span><span style="color:#000000;">
Session.</span><span style="color:#0000ff;">Timestamp</span><span style="color:#000000;"> </span><span style="color:#808080;">&lt;=</span><span style="color:#000000;"> </span><span style="color:#008000;">@EndDate</span><span style="color:#000000;">
{MyProfileKey}

</span><span style="color:#0000ff;">GROUP</span><span style="color:#000000;"> </span><span style="color:#0000ff;">BY</span><span style="color:#000000;"> IpOwner.Name, IpOwner.Country, ProfileKeyDefinition.Name  

</span><span style="color:#0000ff;">ORDER</span><span style="color:#000000;"> </span><span style="color:#0000ff;">BY</span><span style="color:#000000;"> Prof, Score </span><span style="color:#0000ff;">DESC</span><span style="color:#000000;">, IpOwner.Name
</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></p>
<p><strong>Note:</strong> This query also contains the placeholder for the profile key filter <em>MyProfileKey </em>that I created in my previous blog.</p>
</div>
<p>6. Click <strong>OK</strong> and save your changes in the report designer.</p>
<p>My next post: Step 4 &#8211; <a href="http://cbushnell.wordpress.com/2009/11/02/creating-a-top-records-filter-in-sitecore-oms-2/">Configure your Sitecore Filter Definition Item</a></p>
</div>
</div>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cbushnell.wordpress.com/386/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cbushnell.wordpress.com/386/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cbushnell.wordpress.com/386/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cbushnell.wordpress.com/386/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cbushnell.wordpress.com/386/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cbushnell.wordpress.com/386/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cbushnell.wordpress.com/386/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cbushnell.wordpress.com/386/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cbushnell.wordpress.com/386/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cbushnell.wordpress.com/386/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cbushnell.wordpress.com&blog=9791478&post=386&subd=cbushnell&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://cbushnell.wordpress.com/2009/11/02/creating-a-top-records-filter-in-sitecore-oms/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c5c6495ef08d15440e64b4ec73673844?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cbushnell</media:title>
		</media:content>

		<media:content url="http://cbushnell.files.wordpress.com/2009/11/maxrecordsvariable_thumb.png" medium="image">
			<media:title type="html">MaxRecords variable</media:title>
		</media:content>
	</item>
		<item>
		<title>Creating a Top Records Filter in Sitecore OMS</title>
		<link>http://cbushnell.wordpress.com/2009/11/02/creating-a-top-records-report-filter-3/</link>
		<comments>http://cbushnell.wordpress.com/2009/11/02/creating-a-top-records-report-filter-3/#comments</comments>
		<pubDate>Mon, 02 Nov 2009 12:45:33 +0000</pubDate>
		<dc:creator>cbushnell</dc:creator>
				<category><![CDATA[Sitecore OMS reports]]></category>

		<guid isPermaLink="false">http://cbushnell.wordpress.com/?p=383</guid>
		<description><![CDATA[Step 2: Create your Filter Implementation in Visual Studio<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cbushnell.wordpress.com&blog=9791478&post=383&subd=cbushnell&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><h4>Step 2: Create your Filter Implementation in Visual Studio</h4>
<p>To create a new report filter, you must use Visual Studio and create a new C# class. Alternatively, re-use an existing filter, such as <em>WhereSpecificProfileKey</em> from my last blog. If you do this, re-name and edit the existing C# class file.</p>
<p>· Make sure that your class includes the following references and inherits from the <em>Operator Filter Base </em>class:</p>
<p>· Sitecore.Kernel</p>
<p>· Sitecore.Analytics</p>
<div id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:0f54c975-7c01-412d-bca0-0408909eabb0" class="wlWriterEditableSmartContent" style="display:inline;float:none;margin:0;padding:0;">
<pre style="background-color:#ffffff;white-space:pre-wrap;overflow:auto;"><span style="color:#0000ff;">public</span><span style="color:#000000;"> </span><span style="color:#0000ff;">class</span><span style="color:#000000;"> WhereTopRecords : OperatorFilterBase</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></p>
<p>· Your filter class, uses the following two methods:</p>
<p><em>a. </em><em>ApplyFilter</em></p>
<p><em>b. </em><em>IsApplicable</em></p>
<p> Use these two methods for all filter implementations.</p>
<h5>C# code used in this filter</h5>
<div id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:2222f8e3-20aa-419f-98d1-e42378703225" class="wlWriterEditableSmartContent" style="display:inline;float:none;margin:0;padding:0;">
<pre style="background-color:#ffffff;white-space:pre-wrap;overflow:auto;"><span style="color:#0000ff;">using</span><span style="color:#000000;"> System;
</span><span style="color:#0000ff;">using</span><span style="color:#000000;"> System.Data;
</span><span style="color:#0000ff;">using</span><span style="color:#000000;"> System.Configuration;
</span><span style="color:#0000ff;">using</span><span style="color:#000000;"> System.Web;
</span><span style="color:#0000ff;">using</span><span style="color:#000000;"> System.Web.Security;
</span><span style="color:#0000ff;">using</span><span style="color:#000000;"> System.Web.UI;
</span><span style="color:#0000ff;">using</span><span style="color:#000000;"> System.Web.UI.WebControls;
</span><span style="color:#0000ff;">using</span><span style="color:#000000;"> System.Web.UI.WebControls.WebParts;
</span><span style="color:#0000ff;">using</span><span style="color:#000000;"> System.Web.UI.HtmlControls;
</span><span style="color:#0000ff;">using</span><span style="color:#000000;"> Sitecore.Analytics.Data.Filters.Filters;
</span><span style="color:#0000ff;">using</span><span style="color:#000000;"> Sitecore.Analytics.Data.Filters;
</span><span style="color:#0000ff;">using</span><span style="color:#000000;"> Sitecore.Diagnostics;

</span><span style="color:#0000ff;">namespace</span><span style="color:#000000;"> </span><span style="color:#000000;">&lt;</span><span style="color:#000000;">your project name</span><span style="color:#000000;">&gt;</span><span style="color:#000000;">.sitecore_modules.</span><span style="color:#000000;">&lt;</span><span style="color:#000000;">your project folder</span><span style="color:#000000;">&gt;</span><span style="color:#000000;">
{
    </span><span style="color:#0000ff;">public</span><span style="color:#000000;"> </span><span style="color:#0000ff;">class</span><span style="color:#000000;"> WhereTopRecords : OperatorFilterBase
    {

        </span><span style="color:#0000ff;">public</span><span style="color:#000000;"> </span><span style="color:#0000ff;">string</span><span style="color:#000000;"> value;

        </span><span style="color:#008000;">//</span><span style="color:#008000;"> Methods</span><span style="color:#008000;">
</span><span style="color:#000000;">        </span><span style="color:#0000ff;">public</span><span style="color:#000000;"> </span><span style="color:#0000ff;">override</span><span style="color:#000000;"> </span><span style="color:#0000ff;">void</span><span style="color:#000000;"> ApplyFilter(SqlCommand sqlCommand)
        {
            Assert.ArgumentNotNull(sqlCommand, </span><span style="color:#800000;">"</span><span style="color:#800000;">sqlCommand</span><span style="color:#800000;">"</span><span style="color:#000000;">);
            </span><span style="color:#0000ff;">string</span><span style="color:#000000;"> @operator </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#0000ff;">base</span><span style="color:#000000;">.GetOperator();
            sqlCommand.AddWhereClause(</span><span style="color:#800000;">"</span><span style="color:#800000;">MaxRecords</span><span style="color:#800000;">"</span><span style="color:#000000;">, Value, </span><span style="color:#0000ff;">false</span><span style="color:#000000;">);
        }

        </span><span style="color:#0000ff;">public</span><span style="color:#000000;"> </span><span style="color:#0000ff;">override</span><span style="color:#000000;"> </span><span style="color:#0000ff;">bool</span><span style="color:#000000;"> IsApplicable(SqlCommand sqlCommand)
        {
            Assert.ArgumentNotNull(sqlCommand, </span><span style="color:#800000;">"</span><span style="color:#800000;">sqlCommand</span><span style="color:#800000;">"</span><span style="color:#000000;">);
            </span><span style="color:#0000ff;">return</span><span style="color:#000000;"> (sqlCommand.HasPlaceholder(</span><span style="color:#800000;">"</span><span style="color:#800000;">MaxRecords</span><span style="color:#800000;">"</span><span style="color:#000000;">));
        }

        </span><span style="color:#008000;">//</span><span style="color:#008000;">Properties   </span><span style="color:#008000;">
</span><span style="color:#000000;">        </span><span style="color:#0000ff;">public</span><span style="color:#000000;"> </span><span style="color:#0000ff;">string</span><span style="color:#000000;"> Value
        {
            </span><span style="color:#0000ff;">get</span><span style="color:#000000;">
            {
                </span><span style="color:#0000ff;">return</span><span style="color:#000000;"> (</span><span style="color:#0000ff;">this</span><span style="color:#000000;">.value </span><span style="color:#000000;">??</span><span style="color:#000000;"> </span><span style="color:#800000;">"</span><span style="color:#800000;">1000</span><span style="color:#800000;">"</span><span style="color:#000000;">);
            }
            </span><span style="color:#0000ff;">set</span><span style="color:#000000;">
            {
                Assert.ArgumentNotNull(value, </span><span style="color:#800000;">"</span><span style="color:#800000;">value</span><span style="color:#800000;">"</span><span style="color:#000000;">);
                </span><span style="color:#0000ff;">int</span><span style="color:#000000;"> defaultValue </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#800080;">1000</span><span style="color:#000000;">;
                Int32.TryParse(value, </span><span style="color:#0000ff;">out</span><span style="color:#000000;"> defaultValue);
                </span><span style="color:#0000ff;">this</span><span style="color:#000000;">.value </span><span style="color:#000000;">=</span><span style="color:#000000;"> defaultValue.ToString();
            }
        }

    }
}</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></p>
<p>You can either copy and paste this code into your C# class file or use the <em>ApplyFilter</em> and <em>IsApplicable</em> methods to construct your own code solution.</p>
<h5>Explaining the code:</h5>
<p>In my previous blog post, I explained the standard code to include in a filter implementation. In this post, I will only include the sections that are important to this filter.</p>
<h5>Variables</h5>
<p>Declare the following variable. This variable is used in the Properties section of your class and holds a value for the TOP clause entered by an end-user.</p>
<div id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:d81455f7-9c5b-49ee-9c16-59b5483ad304" class="wlWriterEditableSmartContent" style="display:inline;float:none;margin:0;padding:0;">
<pre style="background-color:#ffffff;white-space:pre-wrap;overflow:auto;"><span style="color:#008000;">//</span><span style="color:#008000;"> Fields</span><span style="color:#008000;">
</span><span style="color:#000000;">        </span><span style="color:#0000ff;">public</span><span style="color:#000000;"> </span><span style="color:#0000ff;">string</span><span style="color:#000000;"> value;</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></p>
<h5>Methods</h5>
<p><strong>ApplyFilter</strong></p>
<p>This method inserts your filter into the WHERE clause of your SQL query. It also passes parameters, such as a value for the TOP clause to the report engine.</p>
<div id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:04ff65cd-838e-4eed-8d3a-5e99da926901" class="wlWriterEditableSmartContent" style="display:inline;float:none;margin:0;padding:0;">
<pre style="background-color:#ffffff;white-space:pre-wrap;overflow:auto;"><span style="color:#008000;">//</span><span style="color:#008000;"> Methods</span><span style="color:#008000;">
</span><span style="color:#0000ff;">public</span><span style="color:#000000;"> </span><span style="color:#0000ff;">override</span><span style="color:#000000;"> </span><span style="color:#0000ff;">void</span><span style="color:#000000;"> ApplyFilter(SqlCommand sqlCommand)
        {
            Assert.ArgumentNotNull(sqlCommand, </span><span style="color:#800000;">"</span><span style="color:#800000;">sqlCommand</span><span style="color:#800000;">"</span><span style="color:#000000;">);
            </span><span style="color:#0000ff;">string</span><span style="color:#000000;"> @operator </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#0000ff;">base</span><span style="color:#000000;">.GetOperator();
            sqlCommand.AddWhereClause(</span><span style="color:#800000;">"</span><span style="color:#800000;">Top</span><span style="color:#800000;">"</span><span style="color:#000000;">, Value, </span><span style="color:#0000ff;">false</span><span style="color:#000000;">);
        }
</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></p>
</div>
<p>Edit the <em>AddWhereClause</em> parameters:</p>
<p>(&lt;Placeholder name&gt;, &lt;where clause&gt;, &lt;isExceptCondition&gt;)</p>
<p>Use the following syntax:</p>
<table border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="213" valign="top"><strong>Parameter</strong></td>
<td width="213" valign="top"><strong>Data type</strong></td>
<td width="213" valign="top"><strong>Value</strong></td>
</tr>
<tr>
<td width="213" valign="top">Placeholder name</td>
<td width="213" valign="top">string</td>
<td width="213" valign="top">MaxRecords – Appears in the SQL query as {MaxRecords}.Use MaxRecords to avoid confusion with SQL TOP.</td>
</tr>
<tr>
<td width="213" valign="top">Where clause</td>
<td width="213" valign="top">string</td>
<td width="213" valign="top">Value –This is a variable containing a top value entered by an end-user.</td>
</tr>
<tr>
<td width="213" valign="top">isExceptCondition</td>
<td width="213" valign="top">boolean</td>
<td width="213" valign="top">False – this determines what should be displayed if there is an error.</td>
</tr>
</tbody>
</table>
<p><strong>IsApplicable</strong></p>
<p>This method determines where to insert your filter using a placeholder. The placeholder must be inserted into the WHERE clause of your SQL query using the following syntax:</p>
<div id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:8799f3d6-cff9-4506-b9cc-074f86f934a1" class="wlWriterEditableSmartContent" style="display:inline;float:none;margin:0;padding:0;">
<pre style="background-color:#ffffff;white-space:pre-wrap;overflow:auto;"><span style="color:#000000;">{placeholder}</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></p>
<p>Normally a SQL TOP clause can only be added to the SELECT part of a SQL query. To make it possible to insert it in the right place, you need to use Transact SQL to create a workaround.</p>
<div id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:4451d4cb-bed0-4bd0-8ec3-3d92034e1381" class="wlWriterEditableSmartContent" style="display:inline;float:none;margin:0;padding:0;">
<pre style="background-color:#ffffff;white-space:pre-wrap;overflow:auto;"><span style="color:#0000ff;">public</span><span style="color:#000000;"> </span><span style="color:#0000ff;">override</span><span style="color:#000000;"> </span><span style="color:#0000ff;">bool</span><span style="color:#000000;"> IsApplicable(SqlCommand sqlCommand)
        {
            Assert.ArgumentNotNull(sqlCommand, </span><span style="color:#800000;">"</span><span style="color:#800000;">sqlCommand</span><span style="color:#800000;">"</span><span style="color:#000000;">);
            </span><span style="color:#0000ff;">return</span><span style="color:#000000;"> (sqlCommand.HasPlaceholder(</span><span style="color:#800000;">"</span><span style="color:#800000;">MaxRecords</span><span style="color:#800000;">"</span><span style="color:#000000;">));
        }</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></p>
<p>You can either use the placeholder name I have used {MaxRecords} or replace this with a placeholder name of your own. Both methods must include the same placeholder name.</p>
<h5>Properties</h5>
<p>Create the following properties.</p>
<p>Use the <em>get</em> and <em>set </em>properties to process user input. If a user enters a value, such as <em>10</em> the filter returns the top 10 records. If the value is left empty then the top 1000 records are returned by default.</p>
<div id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:68569ced-85cd-45e9-a21f-f21e7e346a72" class="wlWriterEditableSmartContent" style="display:inline;float:none;margin:0;padding:0;">
<pre style="background-color:#ffffff;white-space:pre-wrap;overflow:auto;"><span style="color:#008000;">//</span><span style="color:#008000;">Properties   </span><span style="color:#008000;">
</span><span style="color:#000000;">        </span><span style="color:#0000ff;">public</span><span style="color:#000000;"> </span><span style="color:#0000ff;">string</span><span style="color:#000000;"> Value
        {
            </span><span style="color:#0000ff;">get</span><span style="color:#000000;">
            {
                </span><span style="color:#0000ff;">return</span><span style="color:#000000;"> (</span><span style="color:#0000ff;">this</span><span style="color:#000000;">.value </span><span style="color:#000000;">??</span><span style="color:#000000;"> </span><span style="color:#800000;">"</span><span style="color:#800000;">1000</span><span style="color:#800000;">"</span><span style="color:#000000;">);
            }
            </span><span style="color:#0000ff;">set</span><span style="color:#000000;">
            {
                Assert.ArgumentNotNull(value, </span><span style="color:#800000;">"</span><span style="color:#800000;">value</span><span style="color:#800000;">"</span><span style="color:#000000;">);
                </span><span style="color:#0000ff;">int</span><span style="color:#000000;"> defaultValue </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#800080;">1000</span><span style="color:#000000;">;
                Int32.TryParse(value, </span><span style="color:#0000ff;">out</span><span style="color:#000000;"> defaultValue);
                </span><span style="color:#0000ff;">this</span><span style="color:#000000;">.value </span><span style="color:#000000;">=</span><span style="color:#000000;"> defaultValue.ToString();
            }
        }</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></p>
</div>
<p>Compile your code and ensure that it is added to your Sitecore bin folder.</p>
<p><em>C:\Inetpub\wwwroot\&lt;site name&gt;\WebSite\bin</em></p>
<p><em> </em></p>
<p>My next post:  Step 3 &#8211; <a href="http://cbushnell.wordpress.com/2009/11/02/creating-a-top-records-filter-in-sitecore-oms/">Add a TOP Clause to your SQL Query</a></p>
</div>
</div>
</div>
</div>
</div>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cbushnell.wordpress.com/383/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cbushnell.wordpress.com/383/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cbushnell.wordpress.com/383/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cbushnell.wordpress.com/383/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cbushnell.wordpress.com/383/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cbushnell.wordpress.com/383/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cbushnell.wordpress.com/383/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cbushnell.wordpress.com/383/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cbushnell.wordpress.com/383/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cbushnell.wordpress.com/383/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cbushnell.wordpress.com&blog=9791478&post=383&subd=cbushnell&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://cbushnell.wordpress.com/2009/11/02/creating-a-top-records-report-filter-3/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c5c6495ef08d15440e64b4ec73673844?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cbushnell</media:title>
		</media:content>
	</item>
		<item>
		<title>Creating a Top Records Filter in Sitecore OMS</title>
		<link>http://cbushnell.wordpress.com/2009/11/02/creating-a-top-records-report-filter-2/</link>
		<comments>http://cbushnell.wordpress.com/2009/11/02/creating-a-top-records-report-filter-2/#comments</comments>
		<pubDate>Mon, 02 Nov 2009 10:44:16 +0000</pubDate>
		<dc:creator>cbushnell</dc:creator>
				<category><![CDATA[Sitecore OMS reports]]></category>

		<guid isPermaLink="false">http://cbushnell.wordpress.com/?p=382</guid>
		<description><![CDATA[Step 1: Create a Filter Definition Item<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cbushnell.wordpress.com&blog=9791478&post=382&subd=cbushnell&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><h4>Step 1: Create a Filter Definition Item</h4>
<p>A Sitecore report filter consists of a filter definition item, stored in the filter criteria folder and a C# class containing the filter implementation.</p>
<p>To create a filter definition item:</p>
<p>1. Open the Content Editor and in the content tree navigate to the following location.</p>
<p><em>/sitecore/system/Settings/Analytics/Filters/Criteria</em></p>
<p>2. In the ribbon, click <em>Insert from Template</em>. Select the filter template: <em>/System/Analytics/Filter</em></p>
<p><a href="http://cbushnell.files.wordpress.com/2009/11/filtertemplate.png"><img style="display:inline;border:0;" title="filter template" src="http://cbushnell.files.wordpress.com/2009/11/filtertemplate_thumb.png?w=412&#038;h=424" border="0" alt="filter template" width="412" height="424" /></a></p>
<p>3. Name your filter <em>WhereTopRecords</em>.</p>
<p>4. In the <strong>Header</strong> field, enter:</p>
<p><em>where top records returned</em></p>
<p>5. In the <strong>Text </strong>field, enter:<em> </em></p>
<p><em>where top records returned is equal to [value,,,value]</em></p>
<p><em> </em>6. The <strong>Type</strong> field will contain a reference to your Visual Studio filter implementation. Leave this field blank for the moment.</p>
<p><a href="http://cbushnell.files.wordpress.com/2009/11/topfilterdefinitionitem.png"><img style="display:inline;border:0;" title="top filter definition item" src="http://cbushnell.files.wordpress.com/2009/11/topfilterdefinitionitem_thumb.png?w=432&#038;h=245" border="0" alt="top filter definition item" width="432" height="245" /></a></p>
<p>7. Save your changes.</p>
<p>My next post: Step 2 &#8211; <a href="http://cbushnell.wordpress.com/2009/11/02/creating-a-top-records-report-filter-3/">Create your Filter Implementation in Visual Studio</a></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cbushnell.wordpress.com/382/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cbushnell.wordpress.com/382/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cbushnell.wordpress.com/382/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cbushnell.wordpress.com/382/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cbushnell.wordpress.com/382/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cbushnell.wordpress.com/382/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cbushnell.wordpress.com/382/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cbushnell.wordpress.com/382/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cbushnell.wordpress.com/382/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cbushnell.wordpress.com/382/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cbushnell.wordpress.com&blog=9791478&post=382&subd=cbushnell&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://cbushnell.wordpress.com/2009/11/02/creating-a-top-records-report-filter-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c5c6495ef08d15440e64b4ec73673844?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cbushnell</media:title>
		</media:content>

		<media:content url="http://cbushnell.files.wordpress.com/2009/11/filtertemplate_thumb.png" medium="image">
			<media:title type="html">filter template</media:title>
		</media:content>

		<media:content url="http://cbushnell.files.wordpress.com/2009/11/topfilterdefinitionitem_thumb.png" medium="image">
			<media:title type="html">top filter definition item</media:title>
		</media:content>
	</item>
		<item>
		<title>Creating a Top Records Filter in Sitecore OMS</title>
		<link>http://cbushnell.wordpress.com/2009/11/02/creating-a-top-records-report-filter/</link>
		<comments>http://cbushnell.wordpress.com/2009/11/02/creating-a-top-records-report-filter/#comments</comments>
		<pubDate>Mon, 02 Nov 2009 10:36:15 +0000</pubDate>
		<dc:creator>cbushnell</dc:creator>
				<category><![CDATA[Sitecore OMS reports]]></category>

		<guid isPermaLink="false">http://cbushnell.wordpress.com/?p=377</guid>
		<description><![CDATA[Create a report filter that enables you to limit the records displayed in a report.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cbushnell.wordpress.com&blog=9791478&post=377&subd=cbushnell&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><h4>Introduction</h4>
<p>Welcome to my third Sitecore blog on creating OMS reports.</p>
<p>In this post, I will create a “top” filter that limits the records displayed in a report. To do this you would normally hard code a SQL TOP clause into your SQL query but in this blog I will demonstrate how you can achieve the same result by creating a filter.</p>
<p>A “top” filter could allow an end-user to enter any numerical value of their own, such as top 10 or top 100. This would make it easier for a marketer to see at a glance which leads are the most important to follow up and is better for performance than displaying every record in the database.</p>
<p><a href="http://cbushnell.files.wordpress.com/2009/11/topfilterfinished.png"><img style="display:inline;border:0;" title="top filter finished" src="http://cbushnell.files.wordpress.com/2009/11/topfilterfinished_thumb.png?w=455&#038;h=317" border="0" alt="top filter finished" width="455" height="317" /></a> </p>
<p>We realized that this would be something “nice to have” in the product and the solution presented here is one way of achieving this. However, it is not a typical approach. For example, we don’t recommend the use of TSQL in your SQL queries as this can cause problems when migrating from a SQL Server to an Oracle database. This blog merely demonstrates some of the possibilities available to developers when creating Sitecore OMS reports. As a report analyst, if you have enough in-depth knowledge of the SQL query language and some programming experience, you can create almost any filter or report you need. The only limitations are the contents of your database tables and your own imagination!</p>
<h4>Prerequisites</h4>
<p>When you create a new filter, you place the logic behind the filter in a C# class file. Therefore to create new filters it is necessary to have some knowledge of C# and Visual Studio.</p>
<p>You also need to install the following:</p>
<ul>· Sitecore OMS</ul>
<ul>· Stimulsoft Report Designer (Stimulsoft Reports.Net 2009.2)</ul>
<ul>· Visual Studio 2005 or 2008</ul>
<p><strong>Optional step:</strong> You can add a filter to any existing report but in this blog I will duplicate the <em>ProfileKeyFilter</em> report I created in my previous blog and rename it <em>ProfileKeyFilterTop</em>. This is an optional step which makes it easier to test your filter without affecting you other existing reports. It also means that you are working with the same data sources and SQL query.</p>
<h4>Creating a Top Filter</h4>
<p>To create a new filter, you need to complete the following steps:</p>
<ul>· Create a Filter Definition Item</ul>
<ul>· Create your Visual Studio Filter Implementation</ul>
<ul>· Add a Top Clause to your SQL Query· Configure your Sitecore Definition Item</ul>
<ul>· Test your Top Filter</ul>
<ul>My next post: Step 1 &#8211; <a href="http://cbushnell.wordpress.com/2009/11/02/creating-a-top-records-report-filter-2/">Create a Filter Definition Item</a></ul>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cbushnell.wordpress.com/377/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cbushnell.wordpress.com/377/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cbushnell.wordpress.com/377/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cbushnell.wordpress.com/377/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cbushnell.wordpress.com/377/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cbushnell.wordpress.com/377/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cbushnell.wordpress.com/377/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cbushnell.wordpress.com/377/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cbushnell.wordpress.com/377/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cbushnell.wordpress.com/377/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cbushnell.wordpress.com&blog=9791478&post=377&subd=cbushnell&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://cbushnell.wordpress.com/2009/11/02/creating-a-top-records-report-filter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c5c6495ef08d15440e64b4ec73673844?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cbushnell</media:title>
		</media:content>

		<media:content url="http://cbushnell.files.wordpress.com/2009/11/topfilterfinished_thumb.png" medium="image">
			<media:title type="html">top filter finished</media:title>
		</media:content>
	</item>
		<item>
		<title>Creating a Report Filter in Sitecore OMS</title>
		<link>http://cbushnell.wordpress.com/2009/10/22/creating-a-report-filter-in-sitecore-oms-6/</link>
		<comments>http://cbushnell.wordpress.com/2009/10/22/creating-a-report-filter-in-sitecore-oms-6/#comments</comments>
		<pubDate>Thu, 22 Oct 2009 17:53:14 +0000</pubDate>
		<dc:creator>cbushnell</dc:creator>
				<category><![CDATA[Sitecore OMS reports]]></category>

		<guid isPermaLink="false">http://cbushnell.wordpress.com/?p=339</guid>
		<description><![CDATA[How to create a Sitecore OMS report filter step 5<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cbushnell.wordpress.com&blog=9791478&post=339&subd=cbushnell&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><h4>Step 5: Test your Filter</h4>
<p>View your new report and test your filter in Sitecore Analytics.</p>
<p>1. In Sitecore Analytics, to refresh your reports, close and then expand the Reports node.</p>
<p>2. Click on your new report: <em>ProfileKeyFilter</em></p>
<p>3. You should see an unfiltered report that displays all profile keys in the Nicam site.</p>
<p>4. Click Filter. You should see your new filter displayed in the Filter Editor window.</p>
<p><a href="http://cbushnell.files.wordpress.com/2009/10/profilekeyfilter1.png"><img style="display:inline;border-width:0;" title="profile key filter" src="http://cbushnell.files.wordpress.com/2009/10/profilekeyfilter_thumb1.png?w=270&#038;h=292" border="0" alt="profile key filter" width="270" height="292" /></a></p>
<p>5. Select the filter and then click <em>specific value</em>.</p>
<p>6. The <strong>Select Profile Key</strong> dialog box, displays all profiles and profile keys. Select a profile key, such as <em>Semi-pro</em>.</p>
<p><a href="http://cbushnell.files.wordpress.com/2009/10/selectprofilekey1.png"><img style="display:inline;border-width:0;" title="select profile key" src="http://cbushnell.files.wordpress.com/2009/10/selectprofilekey_thumb1.png?w=187&#038;h=272" border="0" alt="select profile key" width="187" height="272" /></a></p>
<p>7. Click OK in the <strong>Select Profile Key</strong> dialog box and the <strong>Filter Editor</strong> window. You should see the following report filtered by the Semi-pro profile key:</p>
<p><a href="http://cbushnell.files.wordpress.com/2009/10/filtersemipro.png"><img style="display:inline;border-width:0;" title="Filter-Semi-pro" src="http://cbushnell.files.wordpress.com/2009/10/filtersemipro_thumb.png?w=428&#038;h=421" border="0" alt="Filter-Semi-pro" width="428" height="421" /></a></p>
<p>You can now use this filter this report to show the top scores and organizations for any given profile key in the Nicam site.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cbushnell.wordpress.com/339/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cbushnell.wordpress.com/339/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cbushnell.wordpress.com/339/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cbushnell.wordpress.com/339/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cbushnell.wordpress.com/339/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cbushnell.wordpress.com/339/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cbushnell.wordpress.com/339/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cbushnell.wordpress.com/339/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cbushnell.wordpress.com/339/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cbushnell.wordpress.com/339/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cbushnell.wordpress.com&blog=9791478&post=339&subd=cbushnell&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://cbushnell.wordpress.com/2009/10/22/creating-a-report-filter-in-sitecore-oms-6/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c5c6495ef08d15440e64b4ec73673844?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cbushnell</media:title>
		</media:content>

		<media:content url="http://cbushnell.files.wordpress.com/2009/10/profilekeyfilter_thumb1.png" medium="image">
			<media:title type="html">profile key filter</media:title>
		</media:content>

		<media:content url="http://cbushnell.files.wordpress.com/2009/10/selectprofilekey_thumb1.png" medium="image">
			<media:title type="html">select profile key</media:title>
		</media:content>

		<media:content url="http://cbushnell.files.wordpress.com/2009/10/filtersemipro_thumb.png" medium="image">
			<media:title type="html">Filter-Semi-pro</media:title>
		</media:content>
	</item>
		<item>
		<title>Creating a Report Filter in Sitecore OMS</title>
		<link>http://cbushnell.wordpress.com/2009/10/22/creating-a-report-filter-in-sitecore-oms-5/</link>
		<comments>http://cbushnell.wordpress.com/2009/10/22/creating-a-report-filter-in-sitecore-oms-5/#comments</comments>
		<pubDate>Thu, 22 Oct 2009 17:50:21 +0000</pubDate>
		<dc:creator>cbushnell</dc:creator>
				<category><![CDATA[Sitecore OMS reports]]></category>

		<guid isPermaLink="false">http://cbushnell.wordpress.com/?p=332</guid>
		<description><![CDATA[How to create a Sitecore OMS report filter step 4<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cbushnell.wordpress.com&blog=9791478&post=332&subd=cbushnell&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><h4>Step 4: Configure your Sitecore Filter Definition Item</h4>
<p>When you have created your filter class and added a placeholder variable to your SQL query you then must configure your Sitecore filter definition item to point to your C# assembly.</p>
<p>1. In the Content Editor, Criteria folder, select your filter definition item.</p>
<p><em>/sitecore/system/Settings/Analytics/Filters/Criteria/WhereSpecificProfileKey</em></p>
<p><a href="http://cbushnell.files.wordpress.com/2009/10/filtertypefield.png"><img style="display:inline;border-width:0;" title="filter type field" src="http://cbushnell.files.wordpress.com/2009/10/filtertypefield_thumb.png?w=512&#038;h=111" border="0" alt="filter type field" width="512" height="111" /></a></p>
<p>2. In the <strong>Type</strong> field, enter the correct path to your C# class and assembly.</p>
<p>ChrisTest.sitecore_modules.Cbtest.WhereSpecificProfileKey,ChrisTest</p>
<p>namespace                                     class name                    assembly</p>
<p> </p>
<p>3. Save your changes.</p>
<p> </p>
<p>My next post: Step 5 – <a href="http://cbushnell.wordpress.com/2009/10/22/creating-a-report-filter-in-sitecore-oms-6/">Test your Filter</a></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cbushnell.wordpress.com/332/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cbushnell.wordpress.com/332/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cbushnell.wordpress.com/332/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cbushnell.wordpress.com/332/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cbushnell.wordpress.com/332/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cbushnell.wordpress.com/332/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cbushnell.wordpress.com/332/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cbushnell.wordpress.com/332/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cbushnell.wordpress.com/332/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cbushnell.wordpress.com/332/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cbushnell.wordpress.com&blog=9791478&post=332&subd=cbushnell&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://cbushnell.wordpress.com/2009/10/22/creating-a-report-filter-in-sitecore-oms-5/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c5c6495ef08d15440e64b4ec73673844?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cbushnell</media:title>
		</media:content>

		<media:content url="http://cbushnell.files.wordpress.com/2009/10/filtertypefield_thumb.png" medium="image">
			<media:title type="html">filter type field</media:title>
		</media:content>
	</item>
		<item>
		<title>Creating a Report Filter in Sitecore OMS</title>
		<link>http://cbushnell.wordpress.com/2009/10/22/creating-a-report-filter-in-sitecore-oms-4/</link>
		<comments>http://cbushnell.wordpress.com/2009/10/22/creating-a-report-filter-in-sitecore-oms-4/#comments</comments>
		<pubDate>Thu, 22 Oct 2009 17:48:24 +0000</pubDate>
		<dc:creator>cbushnell</dc:creator>
				<category><![CDATA[Sitecore OMS reports]]></category>

		<guid isPermaLink="false">http://cbushnell.wordpress.com/?p=329</guid>
		<description><![CDATA[How to create a Sitecore OMS report filter step 3<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cbushnell.wordpress.com&blog=9791478&post=329&subd=cbushnell&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><h4>Step 3: Add a Placeholder to your SQL Query</h4>
<p>To add a filter to a report, you must add a variable to the SQL query in your report .mrt file that has the same name as the placeholder in your C# class. If you open any Sitecore report that contains filters, you can see all the filter variables below the WHERE clause.</p>
<p><a href="http://cbushnell.files.wordpress.com/2009/10/filtersvariables.png"><img style="display:inline;border-width:0;" title="filters variables" border="0" alt="filters variables" src="http://cbushnell.files.wordpress.com/2009/10/filtersvariables_thumb.png?w=186&#038;h=178" width="186" height="178" /></a></p>
<table border="0" cellspacing="0" cellpadding="2" width="499">
<tbody>
<tr>
<td valign="top" width="497"><strong>Tip!           <br /></strong>To add an existing Sitecore filter to a report, simply copy the appropriate filter placeholder into the WHERE clause of the report you want to add it to.          <br />For example, if you add the {IPOwner} placeholder variable to your report you get all the filters related to visitor country as shown in the example in the introduction.</td>
</tr>
</tbody>
</table>
<p>To add your new filter to the <em>Profile Key Filter</em> report:</p>
<p>1. In the Report Designer, click <em>Open Report</em> and locate the file <em>ProfileKeyFilter.mrt</em>.</p>
<p><em>C:\Inetpub\wwwroot\&lt;your site&gt;\WebSite\sitecore\shell\Applications\Analytics\Reports</em></p>
<p>2. First create a variable for your placeholder. In the <strong>Dictionary</strong> panel, click <em>New Item</em>, <em>New Variable</em>.</p>
<p>3. In the <strong>Name</strong> field enter <em>MyProfileKey</em> and enter the same value in the <strong>Alias </strong>field. Keep the Type as string and click OK.</p>
<p><a href="http://cbushnell.files.wordpress.com/2009/10/filterplaceholdervariable.png"><img style="display:inline;border-width:0;" title="filter placeholder variable" border="0" alt="filter placeholder variable" src="http://cbushnell.files.wordpress.com/2009/10/filterplaceholdervariable_thumb.png?w=244&#038;h=226" width="244" height="226" /></a></p>
<p>4. Next, add your variable to the SQL query. Click <em>IPOwners</em> and then click <em>Edit</em> to edit the Data Source. This enables you to make changes directly to your SQL query.</p>
<p>5. Add your placeholder {MyProfileKey} to the WHERE clause of your SQL Query.</p>
<p><a href="http://cbushnell.files.wordpress.com/2009/11/filterplaceholderscreenshot.png"><img style="border-bottom:0;border-left:0;display:inline;border-top:0;border-right:0;" title="filter placeholder screenshot" border="0" alt="filter placeholder screenshot" src="http://cbushnell.files.wordpress.com/2009/11/filterplaceholderscreenshot_thumb.png?w=404&#038;h=471" width="404" height="471" /></a> </p>
<p>6. Click OK and save your changes in the report designer.</p>
<p>My next post: Step 4 – <a href="http://cbushnell.wordpress.com/2009/10/22/creating-a-report-filter-in-sitecore-oms-5/">Configure your Sitecore Filter Definition Item</a></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cbushnell.wordpress.com/329/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cbushnell.wordpress.com/329/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cbushnell.wordpress.com/329/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cbushnell.wordpress.com/329/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cbushnell.wordpress.com/329/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cbushnell.wordpress.com/329/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cbushnell.wordpress.com/329/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cbushnell.wordpress.com/329/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cbushnell.wordpress.com/329/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cbushnell.wordpress.com/329/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cbushnell.wordpress.com&blog=9791478&post=329&subd=cbushnell&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://cbushnell.wordpress.com/2009/10/22/creating-a-report-filter-in-sitecore-oms-4/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c5c6495ef08d15440e64b4ec73673844?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cbushnell</media:title>
		</media:content>

		<media:content url="http://cbushnell.files.wordpress.com/2009/10/filtersvariables_thumb.png" medium="image">
			<media:title type="html">filters variables</media:title>
		</media:content>

		<media:content url="http://cbushnell.files.wordpress.com/2009/10/filterplaceholdervariable_thumb.png" medium="image">
			<media:title type="html">filter placeholder variable</media:title>
		</media:content>

		<media:content url="http://cbushnell.files.wordpress.com/2009/11/filterplaceholderscreenshot_thumb.png" medium="image">
			<media:title type="html">filter placeholder screenshot</media:title>
		</media:content>
	</item>
		<item>
		<title>Creating a Report Filter in Sitecore OMS</title>
		<link>http://cbushnell.wordpress.com/2009/10/22/creating-a-report-filter-in-sitecore-oms-3/</link>
		<comments>http://cbushnell.wordpress.com/2009/10/22/creating-a-report-filter-in-sitecore-oms-3/#comments</comments>
		<pubDate>Thu, 22 Oct 2009 15:57:49 +0000</pubDate>
		<dc:creator>cbushnell</dc:creator>
				<category><![CDATA[Sitecore OMS reports]]></category>

		<guid isPermaLink="false">http://cbushnell.wordpress.com/?p=322</guid>
		<description><![CDATA[How to create a Sitecore OMS report filter step 2<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cbushnell.wordpress.com&blog=9791478&post=322&subd=cbushnell&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><h4>Step 2: Create your Filter Implementation in Visual Studio</h4>
<p>To create a new report filter you must use Visual Studio and create a new C# class.</p>
<h5>Create a new C# Class file</h5>
<p>1. Create a new C# project.</p>
<p>2. Create a new C# Class .cs file to add to your project.</p>
<p>3. Make sure that you add the following references to your class:</p>
<p>· Sitecore.Kernel</p>
<p>· Sitecore.Analytics</p>
<p>4. Name your class <em>WhereSpecificProfileKey</em>.</p>
<p>5. Ensure that your new class inherits from the <em>Operator Filter Base </em>class.</p>
<div id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:575ad883-ed14-4e29-a41e-a9933a11b389" class="wlWriterEditableSmartContent" style="display:inline;float:none;margin:0;padding:0;">
<pre style="background-color:#FFFFFF;white-space:pre-wrap;overflow:auto;"><span style="color:#0000FF;">public</span><span style="color:#000000;"> </span><span style="color:#0000FF;">class</span><span style="color:#000000;"> WhereSpecificProfileKey : OperatorFilterBase</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></p>
<p>The Operator filter base contains the functionality you need to create different filter conditions. Filter conditions are like rules that make it easy to create SQL statements to select data from the Analytics database. For example, Sitecore Analytics has a pre-configured filter called <em>Where Profile Key</em> that uses the following operators:</p>
<p>· Select a profile key – From all the keys in the Nicam site.</p>
<p>· Select a comparison – For example, <em>is equal to</em> or <em>is greater than</em></p>
<p>· Enter a value – For example, when score is greater than <em>20</em></p>
<p>To keep things simple, your filter will only contain one condition; the option to choose a profile key from those available in the Nicam site.</p>
<p>The following pop-up window appears when you select this condition in your filter.</p>
<p><a href="http://cbushnell.files.wordpress.com/2009/10/selectprofilekey.png"><img style="display:inline;border-width:0;" title="select profile key" src="http://cbushnell.files.wordpress.com/2009/10/selectprofilekey_thumb.png?w=209&#038;h=289" border="0" alt="select profile key" width="209" height="289" /></a></p>
<p>6. In your new class use the following two methods to create your filter:</p>
<p>· <em>ApplyFilter</em></p>
<p>· <em>IsApplicable</em></p>
<h5>C# code used in this filter</h5>
<div id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:f7c8d476-207c-42a4-9b90-a899c0da725c" class="wlWriterEditableSmartContent" style="display:inline;float:none;margin:0;padding:0;">
<pre style="background-color:#FFFFFF;white-space:pre-wrap;overflow:auto;"><span style="color:#0000FF;">using</span><span style="color:#000000;"> System;
</span><span style="color:#0000FF;">using</span><span style="color:#000000;"> System.Data;
</span><span style="color:#0000FF;">using</span><span style="color:#000000;"> System.Configuration;
</span><span style="color:#0000FF;">using</span><span style="color:#000000;"> System.Web;
</span><span style="color:#0000FF;">using</span><span style="color:#000000;"> System.Web.Security;
</span><span style="color:#0000FF;">using</span><span style="color:#000000;"> System.Web.UI;
</span><span style="color:#0000FF;">using</span><span style="color:#000000;"> System.Web.UI.WebControls;
</span><span style="color:#0000FF;">using</span><span style="color:#000000;"> System.Web.UI.WebControls.WebParts;
</span><span style="color:#0000FF;">using</span><span style="color:#000000;"> System.Web.UI.HtmlControls;
</span><span style="color:#0000FF;">using</span><span style="color:#000000;"> Sitecore.Analytics.Data.Filters.Filters;
</span><span style="color:#0000FF;">using</span><span style="color:#000000;"> Sitecore.Analytics.Data.Filters;
</span><span style="color:#0000FF;">using</span><span style="color:#000000;"> Sitecore.Diagnostics;

</span><span style="color:#0000FF;">namespace</span><span style="color:#000000;"> ChrisTest.sitecore_modules.Cbtest
{
</span><span style="color:#0000FF;">public</span><span style="color:#000000;"> </span><span style="color:#0000FF;">class</span><span style="color:#000000;"> WhereSpecificProfileKey : OperatorFilterBase
  {
    </span><span style="color:#008000;">//</span><span style="color:#008000;"> Fields</span><span style="color:#008000;">
</span><span style="color:#000000;">    </span><span style="color:#0000FF;">private</span><span style="color:#000000;"> </span><span style="color:#0000FF;">string</span><span style="color:#000000;"> profileKeyId;
      </span><span style="color:#008000;">//</span><span style="color:#008000;"> Methods</span><span style="color:#008000;">
</span><span style="color:#000000;">    </span><span style="color:#0000FF;">public</span><span style="color:#000000;"> </span><span style="color:#0000FF;">override</span><span style="color:#000000;"> </span><span style="color:#0000FF;">void</span><span style="color:#000000;"> ApplyFilter(SqlCommand sqlCommand)
          {
            Assert.ArgumentNotNull(sqlCommand, </span><span style="color:#800000;">"</span><span style="color:#800000;">sqlCommand</span><span style="color:#800000;">"</span><span style="color:#000000;">);
            sqlCommand.AddWhereClause(</span><span style="color:#800000;">"</span><span style="color:#800000;">MyProfileKey</span><span style="color:#800000;">"</span><span style="color:#000000;">, </span><span style="color:#800000;">"</span><span style="color:#800000;">ProfileKeyDefinition.ProfileKeyDefinitionId = '</span><span style="color:#800000;">"</span><span style="color:#000000;"> </span><span style="color:#000000;">+</span><span style="color:#000000;"> </span><span style="color:#0000FF;">this</span><span style="color:#000000;">.ProfileKeyId </span><span style="color:#000000;">+</span><span style="color:#000000;"> </span><span style="color:#800000;">"</span><span style="color:#800000;">' </span><span style="color:#800000;">"</span><span style="color:#000000;">, </span><span style="color:#0000FF;">base</span><span style="color:#000000;">.Except);
          }
        </span><span style="color:#0000FF;">public</span><span style="color:#000000;"> </span><span style="color:#0000FF;">override</span><span style="color:#000000;"> </span><span style="color:#0000FF;">bool</span><span style="color:#000000;"> IsApplicable(SqlCommand sqlCommand)
          {
            Assert.ArgumentNotNull(sqlCommand, </span><span style="color:#800000;">"</span><span style="color:#800000;">sqlCommand</span><span style="color:#800000;">"</span><span style="color:#000000;">);
            </span><span style="color:#0000FF;">return</span><span style="color:#000000;"> (sqlCommand.HasPlaceholder(</span><span style="color:#800000;">"</span><span style="color:#800000;">MyProfileKey</span><span style="color:#800000;">"</span><span style="color:#000000;">) );
          }
    </span><span style="color:#008000;">//</span><span style="color:#008000;"> Properties</span><span style="color:#008000;">
</span><span style="color:#000000;">    </span><span style="color:#0000FF;">public</span><span style="color:#000000;"> </span><span style="color:#0000FF;">string</span><span style="color:#000000;"> ProfileKeyId
        {
          </span><span style="color:#0000FF;">get</span><span style="color:#000000;">
          {
          </span><span style="color:#0000FF;">return</span><span style="color:#000000;"> (</span><span style="color:#0000FF;">this</span><span style="color:#000000;">.profileKeyId </span><span style="color:#000000;">??</span><span style="color:#000000;"> </span><span style="color:#0000FF;">string</span><span style="color:#000000;">.Empty);
          }
          </span><span style="color:#0000FF;">set</span><span style="color:#000000;">
        {
          Assert.ArgumentNotNull(value, </span><span style="color:#800000;">"</span><span style="color:#800000;">value</span><span style="color:#800000;">"</span><span style="color:#000000;">);
          </span><span style="color:#0000FF;">this</span><span style="color:#000000;">.profileKeyId </span><span style="color:#000000;">=</span><span style="color:#000000;"> value;
        }
      }
    }
}</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></p>
</div>
<p>You can either copy and paste this code into your C# class file or just use these methods to construct your own logic.</p>
<h5>Explaining the code:</h5>
<p>Include the following namespaces at the top of your filter class:</p>
<div id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:bfee8d82-2543-46e0-a911-d6091caf755d" class="wlWriterEditableSmartContent" style="display:inline;float:none;margin:0;padding:0;">
<pre style="background-color:#FFFFFF;white-space:pre-wrap;overflow:auto;"><span style="color:#0000FF;">using</span><span style="color:#000000;"> System;
</span><span style="color:#0000FF;">using</span><span style="color:#000000;"> System.Data;
</span><span style="color:#0000FF;">using</span><span style="color:#000000;"> System.Configuration;
</span><span style="color:#0000FF;">using</span><span style="color:#000000;"> System.Web;
</span><span style="color:#0000FF;">using</span><span style="color:#000000;"> System.Web.Security;
</span><span style="color:#0000FF;">using</span><span style="color:#000000;"> System.Web.UI;
</span><span style="color:#0000FF;">using</span><span style="color:#000000;"> System.Web.UI.WebControls;
</span><span style="color:#0000FF;">using</span><span style="color:#000000;"> System.Web.UI.WebControls.WebParts;
</span><span style="color:#0000FF;">using</span><span style="color:#000000;"> System.Web.UI.HtmlControls;
</span><span style="color:#0000FF;">using</span><span style="color:#000000;"> Sitecore.Analytics.Data.Filters.Filters;
</span><span style="color:#0000FF;">using</span><span style="color:#000000;"> Sitecore.Analytics.Data.Filters;
</span><span style="color:#0000FF;">using</span><span style="color:#000000;"> Sitecore.Diagnostics;
</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></p>
<p>Declare the following variable:</p>
<div id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:a0539805-11d0-4360-9ca1-3879feb1ff9f" class="wlWriterEditableSmartContent" style="display:inline;float:none;margin:0;padding:0;">
<pre style="background-color:#FFFFFF;white-space:pre-wrap;overflow:auto;"><span style="color:#0000FF;">private</span><span style="color:#000000;"> </span><span style="color:#0000FF;">string</span><span style="color:#000000;"> profileKeyId;</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></p>
<p>This variable is used in the <em>get</em> property of your class.</p>
<p>Use the following two methods:</p>
<h5>ApplyFilter</h5>
<p>The <em>ApplyFilter</em> method allows you to select a profile key from the Nicam site. It then inserts a SQL WHERE clause into the SQL query on your report which retrieves the chosen profile.</p>
<div id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:eeb2895e-bb5a-4df4-9a5c-6750feab4fb4" class="wlWriterEditableSmartContent" style="display:inline;float:none;margin:0;padding:0;">
<pre style="background-color:#FFFFFF;white-space:pre-wrap;overflow:auto;"><span style="color:#0000FF;">public</span><span style="color:#000000;"> </span><span style="color:#0000FF;">override</span><span style="color:#000000;"> </span><span style="color:#0000FF;">void</span><span style="color:#000000;"> ApplyFilter(SqlCommand sqlCommand)
        {
            Assert.ArgumentNotNull(sqlCommand, </span><span style="color:#800000;">"</span><span style="color:#800000;">sqlCommand</span><span style="color:#800000;">"</span><span style="color:#000000;">);
            sqlCommand.AddWhereClause(</span><span style="color:#800000;">"</span><span style="color:#800000;">MyProfileKey</span><span style="color:#800000;">"</span><span style="color:#000000;">, </span><span style="color:#800000;">"</span><span style="color:#800000;">ProfileKeyDefinition.ProfileKeyDefinitionId = '</span><span style="color:#800000;">"</span><span style="color:#000000;"> </span><span style="color:#000000;">+</span><span style="color:#000000;"> </span><span style="color:#0000FF;">this</span><span style="color:#000000;">.ProfileKeyId </span><span style="color:#000000;">+</span><span style="color:#000000;"> </span><span style="color:#800000;">"</span><span style="color:#800000;">' </span><span style="color:#800000;">"</span><span style="color:#000000;">, </span><span style="color:#0000FF;">base</span><span style="color:#000000;">.Except);
        }</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></p>
<h5>IsApplicable</h5>
<p>This method tells your class exactly where in your SQL query to insert the WHERE clause by using a placeholder called MyProfileKey.</p>
<p>The only text you need to change in these methods is the placeholder name. You can either use the same name as I have or replace it with a placeholder name of your own. Both methods must have the same placeholder name.</p>
<div id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:716b6f23-e3a1-416e-9009-198f82e259fc" class="wlWriterEditableSmartContent" style="display:inline;float:none;margin:0;padding:0;">
<pre style="background-color:#FFFFFF;white-space:pre-wrap;overflow:auto;"><span style="color:#0000FF;">public</span><span style="color:#000000;"> </span><span style="color:#0000FF;">override</span><span style="color:#000000;"> </span><span style="color:#0000FF;">bool</span><span style="color:#000000;"> IsApplicable(SqlCommand sqlCommand)
{
    Assert.ArgumentNotNull(sqlCommand, </span><span style="color:#800000;">"</span><span style="color:#800000;">sqlCommand</span><span style="color:#800000;">"</span><span style="color:#000000;">);
    </span><span style="color:#0000FF;">return</span><span style="color:#000000;"> (sqlCommand.HasPlaceholder(</span><span style="color:#800000;">"</span><span style="color:#800000;">MyProfileKey</span><span style="color:#800000;">"</span><span style="color:#000000;">) );
}</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></p>
<h5>Properties</h5>
<p>Create the following properties:</p>
<div id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:e6e94087-0616-4a15-bdc4-4ad31919a732" class="wlWriterEditableSmartContent" style="display:inline;float:none;margin:0;padding:0;">
<pre style="background-color:#FFFFFF;white-space:pre-wrap;overflow:auto;"><span style="color:#008000;">//</span><span style="color:#008000;"> Properties</span><span style="color:#008000;">
</span><span style="color:#0000FF;">public</span><span style="color:#000000;"> </span><span style="color:#0000FF;">string</span><span style="color:#000000;"> ProfileKeyId
{
    </span><span style="color:#0000FF;">get</span><span style="color:#000000;">
    {
    </span><span style="color:#0000FF;">return</span><span style="color:#000000;"> (</span><span style="color:#0000FF;">this</span><span style="color:#000000;">.profileKeyId </span><span style="color:#000000;">??</span><span style="color:#000000;"> </span><span style="color:#0000FF;">string</span><span style="color:#000000;">.Empty);
    }
    </span><span style="color:#0000FF;">set</span><span style="color:#000000;">
    {
    Assert.ArgumentNotNull(value, </span><span style="color:#800000;">"</span><span style="color:#800000;">value</span><span style="color:#800000;">"</span><span style="color:#000000;">);
    </span><span style="color:#0000FF;">this</span><span style="color:#000000;">.profileKeyId </span><span style="color:#000000;">=</span><span style="color:#000000;"> value;
    }
}</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></p>
<p>Compile your code and ensure that it is added to your Sitecore bin folder.</p>
<p><em>C:\Inetpub\wwwroot\&lt;site name&gt;\WebSite\bin</em></p>
<p>My next post: Step 3 – <a href="http://cbushnell.wordpress.com/2009/10/22/creating-a-report-filter-in-sitecore-oms-4/">Add a Placeholder to your SQL Query</a></p>
</div>
</div>
</div>
</div>
</div>
</div>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cbushnell.wordpress.com/322/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cbushnell.wordpress.com/322/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cbushnell.wordpress.com/322/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cbushnell.wordpress.com/322/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cbushnell.wordpress.com/322/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cbushnell.wordpress.com/322/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cbushnell.wordpress.com/322/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cbushnell.wordpress.com/322/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cbushnell.wordpress.com/322/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cbushnell.wordpress.com/322/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cbushnell.wordpress.com&blog=9791478&post=322&subd=cbushnell&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://cbushnell.wordpress.com/2009/10/22/creating-a-report-filter-in-sitecore-oms-3/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c5c6495ef08d15440e64b4ec73673844?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cbushnell</media:title>
		</media:content>

		<media:content url="http://cbushnell.files.wordpress.com/2009/10/selectprofilekey_thumb.png" medium="image">
			<media:title type="html">select profile key</media:title>
		</media:content>
	</item>
	</channel>
</rss>