<?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; Crystal Reports</title>
	<atom:link href="http://cogniza.com/wordpress/tag/crystal-reports/feed/" rel="self" type="application/rss+xml" />
	<link>http://cogniza.com/wordpress</link>
	<description>Business-Intelligence Specialists</description>
	<lastBuildDate>Sat, 30 Apr 2011 13:22:21 +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>Crystal Reports: Dynamic Images</title>
		<link>http://cogniza.com/wordpress/2010/03/15/crystal-reports-dynamic-images/</link>
		<comments>http://cogniza.com/wordpress/2010/03/15/crystal-reports-dynamic-images/#comments</comments>
		<pubDate>Mon, 15 Mar 2010 20:22:31 +0000</pubDate>
		<dc:creator>Craig Buchanan</dc:creator>
				<category><![CDATA[Crystal Reports]]></category>
		<category><![CDATA[Technique]]></category>

		<guid isPermaLink="false">http://cogniza.com/wordpress/?p=167</guid>
		<description><![CDATA[Use a conditional formula to dynamically change the location of a report&#8217;s image.

Add an image to the report (Insert &#124; Picture).  This image will act as a placeholder.  Ensure that the placeholder is the same size as the one that will be dynamically loaded, otherwise the image will be scaled.
Change the image&#8217;s Graphic Location:

right [...]]]></description>
			<content:encoded><![CDATA[<p>Use a conditional formula to dynamically change the location of a report&#8217;s image.<span id="more-167"></span></p>
<ol>
<li>Add an image to the report (Insert | Picture).  This image will act as a placeholder.  Ensure that the placeholder is the same size as the one that will be dynamically loaded, otherwise the image will be scaled.</li>
<li>Change the image&#8217;s Graphic Location:
<ul>
<li>right click image</li>
<li>select Format Graphic&#8230;</li>
<li>select Picture tab</li>
<li>click the conditional-formula button (looks like x+2)</li>
<li>set the formula&#8217;s text to the name of the formula or parameter field that will contain the image&#8217;s URL</li>
<li>save the formula and click the OK button</li>
</ul>
</li>
<li>Save the report</li>
</ol>
<h2>Download</h2>
<p><a href="http://cogniza.com/wordpress/wp-content/uploads/2010/03/Dynamic-Image.11.5.rpt_.zip">Crystal Report Dynamic Image Sample</a></p>
]]></content:encoded>
			<wfw:commentRss>http://cogniza.com/wordpress/2010/03/15/crystal-reports-dynamic-images/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Crystal Reports: FractionToDecimal() Function</title>
		<link>http://cogniza.com/wordpress/2009/09/08/crystal-reports-fractiontodecimal-function/</link>
		<comments>http://cogniza.com/wordpress/2009/09/08/crystal-reports-fractiontodecimal-function/#comments</comments>
		<pubDate>Tue, 08 Sep 2009 18:26:11 +0000</pubDate>
		<dc:creator>Craig Buchanan</dc:creator>
				<category><![CDATA[Crystal Reports]]></category>
		<category><![CDATA[Functions]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.cogniza.com/blog/?p=109</guid>
		<description><![CDATA[Converts a fractional value in the format of Numerator/Denominator or Whole + Numerator/Denominator to a decimal value.


//Assumes values in the following formats:
//99 - integer value
//99.9 - decimal value
//N/D - numerator/denominator
//M N/D - whole + numerator/denominator
Function (Stringvar value)
Local Numbervar whole := 0;
Local Stringvar fraction;
//
value := trim(value);
//integer or decimal format
If IsNumeric(value) Then
    ToNumber(value)
Else (
 [...]]]></description>
			<content:encoded><![CDATA[<p>Converts a fractional value in the format of Numerator/Denominator or Whole + Numerator/Denominator to a decimal value.<br />
<span id="more-109"></span><br />
<code><br />
//Assumes values in the following formats:<br />
//99 - integer value<br />
//99.9 - decimal value<br />
//N/D - numerator/denominator<br />
//M N/D - whole + numerator/denominator<br />
Function (Stringvar value)</p>
<p>Local Numbervar whole := 0;<br />
Local Stringvar fraction;</p>
<p>//<br />
value := trim(value);</p>
<p>//integer or decimal format<br />
If IsNumeric(value) Then<br />
    ToNumber(value)</p>
<p>Else (</p>
<p>    //whole + numerator/denominator<br />
    If InStr(value, " ")>0 Then (</p>
<p>        whole := ToNumber(Split(value, " ")[1]);<br />
        fraction := Split(value, " ")[2];</p>
<p>    )</p>
<p>    //numerator/denominator<br />
    Else (</p>
<p>        fraction := value;</p>
<p>    );</p>
<p>    Local Numbervar numerator := ToNumber(Split(fraction, "/")[1]);<br />
    Local Numbervar denominator := ToNumber(Split(fraction, "/")[2]);</p>
<p>    whole + (numerator / denominator);<br />
)<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://cogniza.com/wordpress/2009/09/08/crystal-reports-fractiontodecimal-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Crystal Reports: Strategy to Localize a Report (labels)</title>
		<link>http://cogniza.com/wordpress/2009/07/09/crystal-reports-strategy-to-localize-a-report-labels/</link>
		<comments>http://cogniza.com/wordpress/2009/07/09/crystal-reports-strategy-to-localize-a-report-labels/#comments</comments>
		<pubDate>Thu, 09 Jul 2009 15:05:06 +0000</pubDate>
		<dc:creator>Craig Buchanan</dc:creator>
				<category><![CDATA[Business Objects Enterprise]]></category>
		<category><![CDATA[Crystal Reports]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Technique]]></category>
		<category><![CDATA[Localization]]></category>

		<guid isPermaLink="false">http://www.cogniza.com/blog/?p=55</guid>
		<description><![CDATA[Create a Crystal Report that dynamically recalculate its labels based on the Workstation&#8217;s localization settings.

ContentLocale
Crystal Reports XI introduced a keyword named &#8216;ContentLocale&#8217;. This keyword returns the machine&#8217;s locale setting (e.g. &#8216;en_US&#8217; for English (US)).  This value is set in Windows&#8217; Regional Settings Control Panel.
However, this keyword can only be used in formulae that are executed [...]]]></description>
			<content:encoded><![CDATA[<p>Create a Crystal Report that dynamically recalculate its labels based on the Workstation&#8217;s localization settings.</p>
<p><span id="more-55"></span></p>
<h3>ContentLocale</h3>
<p>Crystal Reports XI introduced a keyword named &#8216;ContentLocale&#8217;. This keyword returns the machine&#8217;s locale setting (e.g. &#8216;en_US&#8217; for English (US)).  This value is set in Windows&#8217; Regional Settings Control Panel.</p>
<p>However, this keyword can only be used in formulae that are executed during the report&#8217;s <a href="http://www.cogniza.com/blog/?p=12">Second Pass</a>. The following Record Selection Formula, for example, will generate an error:</p>
<p><code>{my_table.localeName}=ContentLocale </code></p>
<h3>Custom Functions</h3>
<p>This keyword, however, can be used in combination with a Report Custom Function to dynamically and transparently apply localization settings when a report is viewed, even reports that have been saved with data or have been scheduled using Business Objects Enterprise.</p>
<p>//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
// Return a localized string for a given Key and Language.<br />
//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
Function (Stringvar Key, Stringvar Language)</p>
<p>//define array of keys that are used by Formula fields<br />
Stringvar Array Keys:=["COUNTRY","REGION","CITY"];</p>
<p>//define an array of localized strings for each required language; ensure localized strings are same position as the Key array (correlated arrays).</p>
<p>//determine which array to use<br />
Stringvar Array Values;<br />
Select Language<br />
Case &#8220;en_US&#8221;: Values:=["Country","State","City"]<br />
Case &#8220;it_IT&#8221;: Values:=["Paese","Dichiari","Citta"]<br />
Case &#8220;fr_FR&#8221;: Values:=["Pays","S","C"]<br />
Default: Values:=["Country","State","City"]<br />
;</p>
<p>//set value&#8217;s default value to the Key; useful for debugging purposes.<br />
Stringvar value:=Key;</p>
<p>//iterate through Key array&#8230;<br />
Numbervar i;<br />
for i := 1 To Ubound(Keys) do (<br />
//if value in array matches the specified value, return the value from the localized array<br />
if Keys[i] = Key then (<br />
value:=Values[i];<br />
exit for<br />
)<br />
);</p>
<p>//return value<br />
value;</p>
<h3>Formula Fields</h3>
<p>Create a Formula Field that will act as a label for each desired Key.  Add it to the report&#8217;s canvas.</p>
<p>//{@Country}<br />
getLocalizedString (&#8220;COUNTRY&#8221;, ContentLocale)</p>
<p>//{@Region}<br />
getLocalizedString (&#8220;REGION&#8221;, ContentLocale)</p>
<p>//{@City}<br />
getLocalizedString (&#8220;CITY&#8221;, ContentLocale)</p>
<h4>Advantages</h4>
<ul>
<li>Rapid development and deployment.</li>
<li>Executes during &#8216;view&#8217; time.</li>
<li>Can be saved to Repository and shared with other reports.</li>
</ul>
<h4>Limitations</h4>
<ul>
<li>Crystal Reports is required to maintain the logic and publish changes to the Repository.</li>
<li>Array of Key/Values limited to 1000 items.</li>
</ul>
<h3>Summary</h3>
<p>This approach should help ease the burden of localizing the labels contained in a Crystal Report.</p>
<h3>Download</h3>
<p><a href="/wordpress/wp-content/Report Localization [custom function].12.000.rpt" target="_new">Sample report</a><br />
<a href="/wordpress/wp-content/xtreme.zip" target="_new">Sample database</a></p>
]]></content:encoded>
			<wfw:commentRss>http://cogniza.com/wordpress/2009/07/09/crystal-reports-strategy-to-localize-a-report-labels/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Crystal Reports: Array_PushEx() Function</title>
		<link>http://cogniza.com/wordpress/2008/01/09/crystal-reports-array_pushex-function/</link>
		<comments>http://cogniza.com/wordpress/2008/01/09/crystal-reports-array_pushex-function/#comments</comments>
		<pubDate>Wed, 09 Jan 2008 20:26:20 +0000</pubDate>
		<dc:creator>Craig Buchanan</dc:creator>
				<category><![CDATA[Crystal Reports]]></category>
		<category><![CDATA[Functions]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.cogniza.com/blog/?p=105</guid>
		<description><![CDATA[Add a unique string value to an array of string values. Uses the delimiter to convert the value into an array.

Function (Stringvar Array Items, Stringvar Values, Stringvar Delimiter)
    Stringvar Array Temp:=Split(Values,Delimiter);
    Numbervar i;
    For i := 1 To Ubound(Temp) Do (
        If Array_Contains (Items, Temp[i]) = False Then (
            Redim Preserve Items[Ubound(Items)+1];
            Items[Ubound(Items)]:=Temp[i];
        );
    );
    [...]]]></description>
			<content:encoded><![CDATA[<p>Add a unique string value to an array of string values. Uses the delimiter to convert the value into an array.<span id="more-105"></span><br />
<code><br />
Function (Stringvar Array Items, Stringvar Values, Stringvar Delimiter)<br />
    Stringvar Array Temp:=Split(Values,Delimiter);<br />
    Numbervar i;<br />
    For i := 1 To Ubound(Temp) Do (<br />
        If Array_Contains (Items, Temp[i]) = False Then (<br />
            Redim Preserve Items[Ubound(Items)+1];<br />
            Items[Ubound(Items)]:=Temp[i];<br />
        );<br />
    );<br />
    Items;<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://cogniza.com/wordpress/2008/01/09/crystal-reports-array_pushex-function/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Crystal Reports: Array_Push() Function</title>
		<link>http://cogniza.com/wordpress/2008/01/09/crystal-reports-array_push-function/</link>
		<comments>http://cogniza.com/wordpress/2008/01/09/crystal-reports-array_push-function/#comments</comments>
		<pubDate>Wed, 09 Jan 2008 20:21:23 +0000</pubDate>
		<dc:creator>Craig Buchanan</dc:creator>
				<category><![CDATA[Crystal Reports]]></category>
		<category><![CDATA[Functions]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Function]]></category>

		<guid isPermaLink="false">http://www.cogniza.com/blog/?p=104</guid>
		<description><![CDATA[Add a string value to an array of strings, only if string value hasn&#8217;t already been added to the array.
Function (Stringvar Array Items, Stringvar Value)
    If Array_Contains (Items, Value) = False Then (
        Redim Preserve Items[Ubound(Items)+1];
        Items[Ubound(Items)]:=Value;
    );
    Items;

]]></description>
			<content:encoded><![CDATA[<p>Add a string value to an array of strings, only if string value hasn&#8217;t already been added to the array.<span id="more-104"></span><code><br />
Function (Stringvar Array Items, Stringvar Value)<br />
    If Array_Contains (Items, Value) = False Then (<br />
        Redim Preserve Items[Ubound(Items)+1];<br />
        Items[Ubound(Items)]:=Value;<br />
    );<br />
    Items;<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://cogniza.com/wordpress/2008/01/09/crystal-reports-array_push-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Crystal Reports: Array_Contains() Function</title>
		<link>http://cogniza.com/wordpress/2008/01/09/crystal-reports-array_contains-function/</link>
		<comments>http://cogniza.com/wordpress/2008/01/09/crystal-reports-array_contains-function/#comments</comments>
		<pubDate>Wed, 09 Jan 2008 20:16:34 +0000</pubDate>
		<dc:creator>Craig Buchanan</dc:creator>
				<category><![CDATA[Crystal Reports]]></category>
		<category><![CDATA[Functions]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.cogniza.com/blog/?p=103</guid>
		<description><![CDATA[Determines if a string value is contained in an array of strings.

Function (Stringvar Array Items, Stringvar Value)
     Numbervar i;
  Booleanvar flag:=False;
     If Ubound(Items)&#62;0 Then
      For i := 1 To Ubound(Items) Do (
            If Items[i]=Value Then (
                flag:=True;
                Exit For
            )
        )
    //End If
    ;
//return result
flag;

]]></description>
			<content:encoded><![CDATA[<p>Determines if a string value is contained in an array of strings.<br />
<span id="more-103"></span><code><br />
Function (Stringvar Array Items, Stringvar Value)<br />
     Numbervar i;<br />
  Booleanvar flag:=False;<br />
     If Ubound(Items)&gt;0 Then<br />
      For i := 1 To Ubound(Items) Do (<br />
            If Items[i]=Value Then (<br />
                flag:=True;<br />
                Exit For<br />
            )<br />
        )<br />
    //End If<br />
    ;<br />
//return result<br />
flag;<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://cogniza.com/wordpress/2008/01/09/crystal-reports-array_contains-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Crystal Reports: Display a Message When Report Has No Data</title>
		<link>http://cogniza.com/wordpress/2007/08/28/crystal-reports-display-a-message-when-report-has-no-data/</link>
		<comments>http://cogniza.com/wordpress/2007/08/28/crystal-reports-display-a-message-when-report-has-no-data/#comments</comments>
		<pubDate>Tue, 28 Aug 2007 16:47:04 +0000</pubDate>
		<dc:creator>Craig Buchanan</dc:creator>
				<category><![CDATA[Business Objects Enterprise]]></category>
		<category><![CDATA[Crystal Reports]]></category>
		<category><![CDATA[Technique]]></category>
		<category><![CDATA[Business Objects]]></category>

		<guid isPermaLink="false">http://www.cogniza.com/blog/?p=98</guid>
		<description><![CDATA[Often it is desirable to display a message, such as 'No matching records', when a report does not contain data. Unfortunately, Crystal Reports does not have a function to easily identify this state.]]></description>
			<content:encoded><![CDATA[<p>Often it is desirable to display a message, such as &#8216;No matching records&#8217;, when a report does not contain data.  Unfortunately, Crystal Reports does not have a function to easily identify this state.</p>
<p><span id="more-98"></span></p>
<p>Fortunately, this functionality can be approximated by building a formula that manually counts the records.  This formula, excuted during the report&#8217;s &#8216;WhileReadingRecords&#8217; phase, will increment a Global variable.  To work correctly, this formula will need to reside in the report&#8217;s Details section.</p>
<p>To build a report that uses this functionality, follow these steps:</p>
<ol>
<li>Create a formula named &#8216;Records&#8217;.</li>
<li>Set the formula&#8217;s text to be:<br />
<code>//Excute this formula as records are read into the report<br />
WhileReadingRecords;<br />
//define a variable that is available throughout the 'main' report<br />
Global Numbervar Records;<br />
//increment the variable<br />
Records:=Records+1;<br />
</code></li>
<li>Place this field in the report&#8217;s Details section.  Suppress the field by checking &#8216;Suppress&#8217; check box on the Format Editor&#8217;s Common tab.</li>
<li>Create a new Page Header section by right-clicking the Page Header section and choose &#8216;Insert Section Below&#8217; from the context menu.</li>
<li>Right-click the newly-created Page Header and choose &#8216;Section Expert&#8230;&#8217; from the context menu.  Check the &#8216;Underlay Following Sections&#8217; checkbox.</li>
<li>Click the Conditional-Formula Editory button to the right of the &#8216;Suppress&#8217; checkbox.  Set the formula&#8217;s text to:<br />
<code>//If the field isn't null, suppress the section; the field will only be null when<br />
//the report does not contain data.<br />
Not(Isnull({@Records}))<br />
</code></li>
<li>Add a Text Object to the report containing the desired message.  Place the Text Object in the newly-created Page Header section.</li>
<li>Test the report.</li>
</ol>
<p><a href="/wordpress/wp-content/uploads/2007/08/usa.pdf" target="_new" class="attachmentlink">Report with Data</a></p>
<p><a href="/wordpress/wp-content/uploads/2007/08/united-states.pdf" target="_new" class="attachmentlink">Report without Data</a></p>
<p><a href="/wordpress/wp-content/uploads/2007/08/no-matching-records-template115.zip" class="attachmentlink">Sample Report</a></p>
]]></content:encoded>
			<wfw:commentRss>http://cogniza.com/wordpress/2007/08/28/crystal-reports-display-a-message-when-report-has-no-data/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Crystal Reports: Common Files Directories</title>
		<link>http://cogniza.com/wordpress/2007/02/15/crystal-reports-common-files-directories/</link>
		<comments>http://cogniza.com/wordpress/2007/02/15/crystal-reports-common-files-directories/#comments</comments>
		<pubDate>Thu, 15 Feb 2007 14:49:15 +0000</pubDate>
		<dc:creator>Craig Buchanan</dc:creator>
				<category><![CDATA[Business Objects Enterprise]]></category>
		<category><![CDATA[Crystal Reports]]></category>
		<category><![CDATA[Business Objects]]></category>

		<guid isPermaLink="false">http://www.cogniza.com/blog/?p=97</guid>
		<description><![CDATA[The location of the Crystal Reports 'Shared' directory has changed over time. When deploying applications that use Crystal Reports, ensure that exporting, user-function library (UFL), and database DLLs are located in the appropriate directory for the version of Crystal Reports that is being used.]]></description>
			<content:encoded><![CDATA[<p>The location of the Crystal Reports &#8216;Shared&#8217; directory has changed over time. When deploying applications that use Crystal Reports, ensure that exporting, user-function library (UFL), and database DLLs are located in the appropriate directory for the version of Crystal Reports that is being used.<span id="more-97"></span></p>
<table>
<tr>
<th>Name</th>
<th>Location</th>
</tr>
<tr>
<td>Crystal Reports 4, 4.5, 5, 6 ,7, 8</td>
<td>&lt;drive&gt;:\WINNT\crystal</td>
</tr>
<tr>
<td>Crystal Reports 8.5</td>
<td>
<ul>
<li>&lt;drive&gt;:\WINNT\crystal</li>
<li>&lt;drive&gt; :\Program Files\Seagate Software\Shared</li>
<li>&lt;drive&gt; :\Program Files\Common Files\Crystal Decisions\2.0\Bin\</li>
</ul>
</td>
</tr>
<tr>
<td>Crystal Reports 9</td>
<td>&lt;drive&gt;:\Program Files\Common Files\Crystal Decisions\2.0\Bin</td>
</tr>
<tr>
<td>Crystal Reports 10</td>
<td>&lt;drive&gt;:\Program Files\Common Files\Crystal Decisions\2.5\Bin</td>
</tr>
<tr>
<td>Crystal Reports.Net 10.2</td>
<td>&lt;drive&gt;:\Program Files\Common Files\Business Objects\2.7\Bin</td>
</tr>
<tr>
<td>Crystal Reports XI</td>
<td>&lt;drive&gt;:\Program Files\Common Files\Business Objects\3.0\bin</td>
</tr>
<tr>
<td>Crystal Reports XI R2</td>
<td>&lt;drive&gt;:\Program Files\Business Objects\common\3.5\bin</td>
</tr>
</table>
]]></content:encoded>
			<wfw:commentRss>http://cogniza.com/wordpress/2007/02/15/crystal-reports-common-files-directories/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Crystal Reports: CDateRange() Function</title>
		<link>http://cogniza.com/wordpress/2006/05/25/crystal-reports-cdaterange-function/</link>
		<comments>http://cogniza.com/wordpress/2006/05/25/crystal-reports-cdaterange-function/#comments</comments>
		<pubDate>Thu, 25 May 2006 12:55:17 +0000</pubDate>
		<dc:creator>Craig Buchanan</dc:creator>
				<category><![CDATA[Functions]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Crystal Reports]]></category>

		<guid isPermaLink="false">http://www.cogniza.com/blog/?p=77</guid>
		<description><![CDATA[A Crystal Reports Custom Function to convert a string value into its equivalent Date Range.]]></description>
			<content:encoded><![CDATA[<p>Convert a string value into its equivalent Date Range.</p>
<p><span id="more-77"></span><code>Function (Stringvar dateRange)<br />
Select dateRange<br />
Case "Aged0To30Days" : Aged0To30Days<br />
Case "Aged31To60Days" : Aged31To60Days<br />
Case "Aged61To90Days" : Aged61To90Days<br />
Case "AllDatesFromToday" : AllDatesFromToday<br />
Case "AllDatesFromTomorrow" : AllDatesFromTomorrow<br />
Case "AllDatesToToday" : AllDatesToToday<br />
Case "AllDatesToYesterday" : AllDatesToYesterday<br />
Case "Calendar1stHalf" : Calendar1stHalf<br />
Case "Calendar1stQtr" : Calendar1stQtr<br />
Case "Calendar2ndHalf" : Calendar2ndHalf<br />
Case "Calendar2ndQtr" : Calendar2ndQtr<br />
Case "Calendar3rdQtr" : Calendar3rdQtr<br />
Case "Calendar4thQtr" : Calendar4thQtr<br />
Case "Last4WeeksToSun" : Last4WeeksToSun<br />
Case "Last7Days" : Last7Days<br />
Case "LastFullMonth" : LastFullMonth<br />
Case "LastFullWeek" : LastFullWeek<br />
Case "LastYearMTD" : LastYearMTD<br />
Case "LastYearYTD" : LastYearYTD<br />
Case "MonthToDate" : MonthToDate<br />
Case "Next30Days" : Next30Days<br />
Case "Next31To60Days" : Next31To60Days<br />
Case "Next61To90Days" : Next61To90Days<br />
Case "Next91To365Days" : Next91To365Days<br />
Case "Over90Days" : Over90Days<br />
Case "WeekToDateFromSun" : WeekToDateFromSun<br />
Case "YearToDate" : YearToDate<br />
Case "Yesterday" : CurrentDate-1 To CurrentDate-1<br />
Default: YearToDate </code></p>
<h3>Parameters</h3>
<dl>
<dt><em>dateRange</em></dt>
<dd>string equivalent of a Crystal Reports&#8217; Date Range.</dd>
</dl>
<h3>Return Value</h3>
<p>Date Range</p>
<h3>Remarks</h3>
<p>This function is useful when a report needs to provide a means to prompt on named date ranges, rather than a starting and ending date.  See <a href="http://www.cogniza.com/blog/?p=61" target="_new">Business Objects Enterprise: Create a dynamic list of date ranges</a> for an example.</p>
<h3>Example</h3>
<p><code>'converts the 'Date Range' parameter (a list of strings) to an actual Date Range.<br />
{Orders.OrderDate} IN CDateRange({?Date Range})<br />
</code></p>
<h3>Requirements</h3>
<p>This function requires the use of Crystal Syntax.</p>
]]></content:encoded>
			<wfw:commentRss>http://cogniza.com/wordpress/2006/05/25/crystal-reports-cdaterange-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<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>

