<?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:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"
	xmlns:media="http://search.yahoo.com/mrss/"
>

<channel>
	<title>Dave's Adventures in Business Intelligence &#187; Calculation Context</title>
	<atom:link href="http://www.dagira.com/category/report-techniques/calculation-context/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dagira.com</link>
	<description>...you are in a twisty maze of passageways, all different...</description>
	<lastBuildDate>Wed, 01 Feb 2012 17:26:45 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<!-- podcast_generator="podPress/8.8" -->
		<copyright>&#xA9; </copyright>
		<managingEditor>blogmaster@dagira.com ()</managingEditor>
		<webMaster>blogmaster@dagira.com()</webMaster>
		<category></category>
		<ttl>1440</ttl>
		<itunes:keywords></itunes:keywords>
		<itunes:subtitle></itunes:subtitle>
		<itunes:summary>...you are in a twisty maze of passageways, all different...</itunes:summary>
		<itunes:author></itunes:author>
		<itunes:category text="Society &amp; Culture"/>
		<itunes:owner>
			<itunes:name></itunes:name>
			<itunes:email>blogmaster@dagira.com</itunes:email>
		</itunes:owner>
		<itunes:block>No</itunes:block>
		<itunes:explicit>no</itunes:explicit>
		<itunes:image href="http://www.dagira.com/wp-content/plugins/podpress/images/powered_by_podpress_large.jpg" />
		<image>
			<url>http://www.dagira.com/wp-content/plugins/podpress/images/powered_by_podpress.jpg</url>
			<title>Dave's Adventures in Business Intelligence</title>
			<link>http://www.dagira.com</link>
			<width>144</width>
			<height>144</height>
		</image>
		<item>
		<title>Calculation Context Part I: Overview</title>
		<link>http://www.dagira.com/2010/01/04/calculation-context-part-i-overview/</link>
		<comments>http://www.dagira.com/2010/01/04/calculation-context-part-i-overview/#comments</comments>
		<pubDate>Mon, 04 Jan 2010 23:28:10 +0000</pubDate>
		<dc:creator>Dave Rathbun</dc:creator>
				<category><![CDATA[Calculation Context]]></category>
		<category><![CDATA[Report Techniques]]></category>

		<guid isPermaLink="false">http://www.dagira.com/?p=229</guid>
		<description><![CDATA[One of the hardest concepts to explain when introducing new folks to Business Objects is context. 
I now imagine blog readers who have been working with the tools for a while have started nodding their heads in agreement, only to stop and say, &#8220;Hey, wait a second, is Dave talking about universe contexts or report [...]]]></description>
			<content:encoded><![CDATA[<p>One of the hardest concepts to explain when introducing new folks to Business Objects is context. </p>
<p><em>I now imagine blog readers who have been working with the tools for a while have started nodding their heads in agreement, only to stop and say, &#8220;Hey, wait a second, is Dave talking about universe contexts or report calculation contexts?&#8221; </em></p>
<p>And the answer is, of course, yes. <img src='http://www.dagira.com/wp-includes/images/smilies/icon_lol.gif' alt=':lol:' class='wp-smiley' /> </p>
<p>Both concepts can be quite complicated and take a while to fully understand. Since I have already written a number of blog posts about universe contexts I thought it was time to turn my attention to the report technique of calculation contexts. Note that this concept is used in Desktop Intelligence and Web Intelligence but not in Crystal. This post is intended to be an overview only. I have plans for a detailed post on each of the various context operators where I will go into much more depth. For this post my goal is to introduce the concept and provide some basic definitions. <span id="more-229"></span></p>
<h3>Introducing Calculation Context</h3>
<p>The default calculation context is defined by the dimensions that participate in a report block. It is this feature that makes the dynamic nature of measures possible. When dimensions are removed from or added to a block the context changes and the measure amounts also change. This is controlled by the <a href="http://www.dagira.com/2009/07/06/sql-aggregate-versus-universe-projection/">projection function set on each measure</a> by the universe designer.</p>
<p>However, a report writer sometimes wants a measure to be fixed at a particular value. Percentages are a really simple example. To calculate a contribution percentage I need to divide each individual value by the overall grand total. In order to do that, I need to know how to generate the grand total anywhere I want it. In order to do <strong>that</strong>, I need to understand how to use the various calculation context operators.</p>
<h3>Context Operators</h3>
<p>There is a simple (but powerful) set of context operators that I can choose from. I intend to briefly define each one in this blog post and then dive into more detail in future posts. As I mentioned when I started, the default context for a measure is based on the dimension values present in the block structure. I can alter which of those dimensions impact the calculation using one of the following three context operators.</p>
<ul>
<li><strong>In</strong> is used to specify exactly which dimensions to include in a context. Other dimensions in the block are ignored. Adding / removing elements from the block does not impact this calculation unless a removed dimension was specified in the context. In that case a #MULTIVALUE error is displayed.</li>
<li><strong>ForEach</strong> is used to <em>include</em> a dimension in a context. The calculation context is still affected by other values in the block.</li>
<li><strong>ForAll</strong> is used to <em>exclude</em> a dimension from a context. Other dimensions of the block will still be considered. Adding or removing values from a block might change the value, but it will always ignore the ForAll items.</li>
</ul>
<p>The operators listed above all require one or more dimensions as part of their syntax. However, calculation context can be specified by more than a set of dimension values. There are a series of report structure keywords that can be used as well.</p>
<ul>
<li><strong>In Report</strong> sets the context at the report or &#8220;grand total&#8221; level. Any formula with these keywords for the context will return an overall total. Note that the total may still be affected by report filters.</li>
<li><strong>In Block</strong> sets the context for each <del datetime="2009-12-04T22:01:55+00:00">block</del> section. For years I have been waiting for this setting to be renamed to reflect how it really works, but it hasn&#8217;t. I suppose it&#8217;s for backwards compatibility. If there is only one block on a report then &#8220;In Block&#8221; and &#8220;In Report&#8221; are going to be the same. But when a block is broken up into sections, then this context will generate a total for each section value. For that reason I submit that a better name might have been &#8220;In Section&#8221; instead, but as long as I know what it does the specific word does not really matter.</li>
<li><strong>In Body</strong> is the standard default context for each row of data. </li>
</ul>
<p>With Desktop Intelligence we have the option of <strong>In CurrentPage</strong> which can be quite useful and unfortunately not yet available in Web Intelligence. I probably don&#8217;t have to explain how the &#8220;CurrentPage&#8221; total is derived. <img src='http://www.dagira.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Finally, these keywords can appear in several places in a formula. The most common are the &#8220;input&#8221; and &#8220;output&#8221; context settings, but certain functions (like <code>RunningSum()</code> for example) also have a &#8220;reset&#8221; context. </p>
<ul>
<li><strong>Input</strong> context is used to determine the input values for the formula.</li>
<li><strong>Output</strong> context is used to determine the output scope of the formula.</li>
<li><strong>Reset</strong> context is used to determine when a running function starts over at zero.</li>
</ul>
<p>Dimensions referenced in the input context do not have to appear in the block. Output and reset dimensions must appear in the block in order to function correctly. For many calculations the default input context works just fine. I will show an example where it&#8217;s crucial to understand input context later on. For now I would like to move on to a simple example.</p>
<h3>Simple Calculation Context Example</h3>
<p>It&#8217;s hard to fully grasp some of the subtleties of calculation context without good examples. For this post I will provide one simple but common example that I mentioned earlier: contribution percent. I will start with a simple block with one dimension (resort), one measure (revenue), and a grand total as shown here.</p>
<p><img src="/tips/calc_context_intro/simple_block.jpg" width="217" height="121" border="0" alt="simple report block" title="Web Intelligence simple report block with grand total" /></p>
<p>This block already has a total on it. If this were a typical spreadsheet I could reference the total value using a row/column address, but that doesn&#8217;t work in Web Intelligence. That means I have to use another technique to generate the grand total. I mentioned the solution earlier&#8230; all I have to do is create a simple formula that looks like this:</p>
<p><img src="/tips/calc_context_intro/formula.jpg" width="511" height="265" border="0" alt="calculation context formula" title="Web Intelligence variable editor with simple calculation context formula" /></p>
<p>Here&#8217;s the formula again:</p>
<p><code>=[Revenue] / [Revenue] In Report</code></p>
<p>Remember that the <strong>In Report</strong> context projects the measure up to the overall report total. By using that calculation context operator in the denominator of my division I ensure that I will always be dividing by the grand total in this formula. The results?</p>
<p><img src="/tips/calc_context_intro/finished_block.jpg" width="325" height="121" border="0" alt="Finished report block" title="Web Intelligence report with context for percent contribution calculation" /></p>
<h3>What&#8217;s Next?</h3>
<p>This post barely scratched the surface of the calculation context question. It provided a few brief definitions and one simple example. I have several other posts planned that will dive into much greater detail about this often confusing subject. First I plan to talk more about In versus ForEach versus ForAll and how they are different. Next I plan to cover input versus output context and when each should be used. As I write this post neither of those two are much more than an outline for now, so I don&#8217;t have an estimated publish date.</p>
<p>But they&#8217;ll get published. Eventually. <img src='http://www.dagira.com/wp-includes/images/smilies/icon_cool.gif' alt='8-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.dagira.com/2010/01/04/calculation-context-part-i-overview/feed/</wfw:commentRss>
		<slash:comments>44</slash:comments>
		</item>
	</channel>
</rss>

