<?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/"
	>

<channel>
	<title>Cogniza &#187; Business View</title>
	<atom:link href="http://cogniza.com/wordpress/tag/business-view/feed/" rel="self" type="application/rss+xml" />
	<link>http://cogniza.com/wordpress</link>
	<description>Business-Intelligence Specialists</description>
	<lastBuildDate>Mon, 15 Mar 2010 20:22:31 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Business Objects Enterprise: Create a Dynamic List of Date Ranges</title>
		<link>http://cogniza.com/wordpress/2006/05/24/business-objects-enterprise-create-a-dynamic-list-of-date-ranges/</link>
		<comments>http://cogniza.com/wordpress/2006/05/24/business-objects-enterprise-create-a-dynamic-list-of-date-ranges/#comments</comments>
		<pubDate>Wed, 24 May 2006 17:38:23 +0000</pubDate>
		<dc:creator>Craig Buchanan</dc:creator>
				<category><![CDATA[Business Objects Enterprise]]></category>
		<category><![CDATA[Crystal Reports]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Technique]]></category>
		<category><![CDATA[Business Objects]]></category>
		<category><![CDATA[Business View]]></category>
		<category><![CDATA[Date/Time]]></category>
		<category><![CDATA[Parameters]]></category>

		<guid isPermaLink="false">http://www.cogniza.com/blog/?p=61</guid>
		<description><![CDATA[Add a dynamic, date-range parameter to a report which includes the most recent 12 months, plus Crystal Reports' Month-to-Date and Year-to-Date ranges.]]></description>
			<content:encoded><![CDATA[<p>Add a dynamic, date-range parameter to a report which includes the most recent 12 months, plus Crystal Reports&#8217; Month-to-Date and Year-to-Date ranges.</p>
<p><a href="/wordpress/wp-content/uploads/2006/05/Date-Range%20Parameter.png" target="_new"><img src="/wordpress/wp-content/uploads/2006/05/Date-Range%20Parameter.png" alt="Date-Range Parameter" id="image62" border="0" height="90" width="128" /></a><span id="more-61"></span></p>
<h2>Objective</h2>
<p>Give the report</p>
<h2>Instructions</h2>
<h3>Create the Sql Server Components</h3>
<p>A Sql Server user-defined function (see <a href="http://www.cogniza.com/wordpress/2006/05/25/sql-server-dateranges-function" target="_new">Sql Server: DateRanges Function</a>) will dynamically create the values that are needed for the this project. This function needs a Sql Server view (see <a href="http://www.cogniza.com/wordpress/2006/05/25/sql-server-getnow-view" target="_new">Sql Server: GetNow View</a>) to generate the system&#8217;s current date/time.</p>
<h3>Create Data Connection</h3>
<ol>
<li>Open the Business View Manager and log in.</li>
<li>Create a new Data Connection.</li>
<li>Configure the Data Connection to attach to the appropriate Sql Server database.</li>
<li>Save the Data Connection as &#8216;Sql Server DC&#8217;.</li>
</ol>
<h3>Create a Data Foundation</h3>
<ol>
<li>In the Business View Manager, create a Data Foundation.</li>
<li>Select &#8216;Sql Server DC&#8217; as the Data Connection.</li>
<li>Save the Data Foundation as &#8216;Sql Server DF&#8217;.</li>
</ol>
<h3>Create a Business View</h3>
<ol>
<li>In the Business View Manager, create a Business View.</li>
<li>Save the Business View as &#8216;Sql Server BV&#8217;.</li>
</ol>
<h3>Create a Command Object</h3>
<ol>
<li>Create a Command Object in the Data Foundation. Add the following text to the Command Object:</li>
<p><code>SELECT *<br />
FROM dbo.DateRanges()<br />
ORDER BY Sequence DESC </code></p>
<li>Save the Command Object as &#8216;DateRanges&#8217;.</li>
</ol>
<p><a href="/wordpress/wp-content/uploads/2006/05/Create%20Command%20Object.png" target="_new"><img src="/wordpress/wp-content/uploads/2006/05/Create%20Command%20Object.thumbnail.png" alt="Create Command Object" id="image65" border="0" height="80" width="128" /></a></p>
<p><a href="/wordpress/wp-content/uploads/2006/05/Data%20Foundation.png" target="_new"><img src="/wordpress/wp-content/uploads/2006/05/Data%20Foundation.thumbnail.png" alt="Data Foundation" id="image75" border="0" height="94" width="128" /></a></p>
<h3>Create a Business Element</h3>
<ol>
<li>Create a new Business Element in the Business View Manager.</li>
<li>Add the Description and Value fields from the &#8216;DateRanges&#8217; Command Object.</li>
<li>Save the Business Element as &#8216;DateRanges&#8217;.</li>
</ol>
<p><a href="/wordpress/wp-content/uploads/2006/05/Business%20Element.png" target="_new"><img src="/wordpress/wp-content/uploads/2006/05/Business%20Element.thumbnail.png" alt="Business Element" id="image63" border="0" height="94" width="128" /></a></p>
<h3>Add Business Element to Business View</h3>
<ol>
<li>Open the Business View.</li>
<li>From the &#8216;Insert&#8217; menu, select &#8216;Insert Business Elements&#8230;&#8217;.</li>
<li>Locate and select the &#8216;DateRanges&#8217; Business Element, click &#8216;Add&#8217;, then &#8216;Close&#8217;.</li>
</ol>
<p><a href="/wordpress/wp-content/uploads/2006/05/Business%20View.png" target="_new"><img src="/wordpress/wp-content/uploads/2006/05/Business%20View.thumbnail.png" alt="Business View" id="image64" border="0" height="94" width="128" /></a></p>
<h3>Create the List of Values</h3>
<ol>
<li>Create a new List of Value in the Business View Manager.</li>
<li>Select the desired Business View from the &#8216;Select Business View&#8217; window.</li>
<li>Enter &#8216;Date Range LoV&#8217; in the &#8216;Name&#8217; textbox.</li>
<li>Expand the &#8216;DateRanges&#8217; Business Element in the &#8216;Available Fields&#8217; list.</li>
<li>Select &#8216;Value&#8217;, then click the &#8216;&gt;&#8217; button.</li>
<li>Check &#8216;Sort by Value in Descending Order&#8217;.</li>
<li>Choose &#8216;Description&#8217; from the &#8216;Description Field&#8217; dropdown list.</li>
<li>Click &#8216;OK&#8217; to save the List of Values.</li>
</ol>
<p><a href="/wordpress/wp-content/uploads/2006/05/Create%20List%20of%20Values.png" target="_new"><img src="/wordpress/wp-content/uploads/2006/05/Create%20List%20of%20Values.thumbnail.png" alt="Create List of Values" id="image66" border="0" height="96" width="112" /></a></p>
<h3>Examine Repository</h3>
<p>Open the Repository Explorer in the Business View Manager.  The list of objects for the Date Range Parameter should resemble this list:</p>
<p><a href="/wordpress/wp-content/uploads/2006/05/Repository%20Explorer.png" target="_new"><img src="/wordpress/wp-content/uploads/2006/05/Repository%20Explorer.thumbnail.png" alt="Repository Explorer" id="image76" border="0" height="96" width="111" /></a></p>
<h3>Create the Dynamic Parameter</h3>
<ol>
<li>Create a new report using Crystal Reports XI.</li>
<li>Connect to the Repository that contains the &#8216;Sql Server BV&#8217; Business View.</li>
<li>Create a new parameter, named &#8216;Date Range&#8217;.  Leave the &#8216;Prompt Group Text&#8217; textfield blank.</li>
<li>Select &#8216;Dynamic&#8217; from the &#8216;List of Values&#8217; dropdown list.</li>
<li>Select the Existing radio button and choose &#8216;Date Range LoV&#8217; from the list.</li>
<li>Click &#8216;Create Parameter&#8217; in the &#8216;Parameters&#8217; column of the &#8216;Choose a Data Source&#8217; group.</li>
<li>Set &#8216;Prompt Text&#8217; to &#8216;Choose Date Range&#8217;.</li>
<li>Set &#8216;Sort Order&#8217; to &#8216;Descending by Value&#8217;.</li>
<li>Set &#8216;Prompt With Description Only&#8217; to &#8216;True&#8217;.</li>
<li>Click &#8216;OK&#8217; to save the parameter.</li>
</ol>
<p><a href="/wordpress/wp-content/uploads/2006/05/Create%20Parameter.png" target="_new"><img src="/wordpress/wp-content/uploads/2006/05/Create%20Parameter.Thumbnail.png" alt="Create Parameter" id="image67" border="0" height="96" width="114" /></a></p>
<h3>Modify the Report</h3>
<ol>
<li>Add the CDateTime Custom Function to the report (see <a href="http://www.cogniza.com/blog/?p=77" title="Crystal Reports: CDateRange Function">Crystal Reports: CDateTime</a>).</li>
<li>Add a Custom Function named &#8216;getDateRange&#8217; (see below) to the report.</li>
<li>Edit the Record Selection Formula. Add the following code:<br />
<code>//set the database field to the value that is extracted from the 'Date Range' parameter<br />
{table.date_field} IN getDateRange({?Date Range})</code></li>
<li>Add a formula field to display the date range.  Add the following code to the formula:<br />
<code>CStr(Minimum(getDateRange ({?Date Range}))) + " - " + CStr(Maximum(getDateRange ({?Date Range})))</code><br />
Add the formula field to the report.</li>
</ol>
<h2>Summary</h2>
<p>When the report is run, the parameter form will resemble:</p>
<p><a href="/wordpress/wp-content/uploads/2006/05/Date-Range%20Parameter.png" target="_new"><img src="/wordpress/wp-content/uploads/2006/05/Date-Range%20Parameter.png" alt="Date-Range Parameter" id="image62" border="0" height="90" width="128" /></a></p>
<p><a href="/wordpress/wp-content/uploads/2006/05/Dynamic%20Date-Range%20Parameter.zip" id="p70">Dynamic Date-Range Parameter Sample</a></p>
<h2>getDateRange Custom Function</h2>
<p><code> '--------------------------------------------------------------------------------<br />
'Author:        Craig <a href="mailto:Buchanan;craig.buchanan@cogniza.com" style="color: #ffcc33" class="linkification-ext" title="Linkification: mailto:Buchanan;craig.buchanan@cogniza.com">Buchanan;craig.buchanan@cogniza.com</a><br />
'Purpose:       Convert a string value into its equivalent Date Range<br />
'Parameters:    text - a string in the format index;startDate:endDate<br />
'               or index;NamedDateRange<br />
'               e.g. 1;1/1/2006:12/31/2006 or 2;MonthToDate<br />
'Returns:       Date Range<br />
'--------------------------------------------------------------------------------<br />
Function getDateRange (text as string) As Date Range<br />
If Instr(text,";")=0 Then Exit Function<br />
Dim value as string: value = Split(text,";")(2)<br />
If Instr(value,":")=0 Then<br />
getDateRange = CDateRange (value)<br />
Else<br />
Dim startDate as Date: startDate = Cdate(Split(value,":")(1))<br />
dim endDate as Date: endDate = cdate(Split(value,":")(2))<br />
getDateRange = startDate to endDate<br />
End If<br />
End Function</code></p>
]]></content:encoded>
			<wfw:commentRss>http://cogniza.com/wordpress/2006/05/24/business-objects-enterprise-create-a-dynamic-list-of-date-ranges/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
