<?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>tim laqua dot com &#187; calculated member</title>
	<atom:link href="http://timlaqua.com/tag/calculated-member/feed/" rel="self" type="application/rss+xml" />
	<link>http://timlaqua.com</link>
	<description>Thoughts and Code from Tim Laqua</description>
	<lastBuildDate>Fri, 03 Feb 2012 23:12:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Wierd Slice &#8211; Revenue for the Most Recent Hour in the Cube Across the Last 14 Days Sliced by Week</title>
		<link>http://timlaqua.com/2009/02/wierd-slice-revenue-for-the-most-recent-hour-in-the-cube-across-the-last-seven-days/</link>
		<comments>http://timlaqua.com/2009/02/wierd-slice-revenue-for-the-most-recent-hour-in-the-cube-across-the-last-seven-days/#comments</comments>
		<pubDate>Tue, 24 Feb 2009 01:12:35 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Scripts & Code]]></category>
		<category><![CDATA[calculated measure]]></category>
		<category><![CDATA[calculated member]]></category>
		<category><![CDATA[cube]]></category>
		<category><![CDATA[mdx]]></category>
		<category><![CDATA[recent hour]]></category>
		<category><![CDATA[ssas]]></category>
		<category><![CDATA[subcube]]></category>
		<category><![CDATA[tail]]></category>

		<guid isPermaLink="false">http://timlaqua.com/?p=64</guid>
		<description><![CDATA[Well - there's two parts to this - one is to figure out the most recent hour in the cube that has data. Let's face it, it finishes as soon as it can - but that time may vary now and then. Then, for this particular report, we wanted to see the last seven days [...]]]></description>
			<content:encoded><![CDATA[<p>Well - there's two parts to this - one is to figure out the most recent hour in the cube that has data.  Let's face it, it finishes as soon as it can - but that time may vary now and then.  Then, for this particular report, we wanted to see the last seven days on one series and the previous seven days on another series.  To do this, we just slice by two calculated measures.  But this creates an odd dateset where the This Week column will have no data for the "Date Time" columns that actually belong to the Previous Week.</p>
<p>This isn't really a problem as in SSRS, you can simply define the Category Group for the Series in your chart (ya, I didn't mention that yet - this is all for a chart) as DatePart("w", Fields!DateTime) - which will group everything by the number of the given weekday and then you can just have your "This Week" and "Prevoius Week" series.</p>

<div class="wp_syntax"><div class="code"><pre class="mdx" style="font-family:monospace;"><span style="color: #0000FF; font-weight: bold;">WITH</span> 
  <span style="color: #0000FF; font-weight: bold;">MEMBER</span> <span style="color: #333333;">[Measures]</span>.<span style="color: #333333;">[This Week]</span> <span style="color: #0000FF; font-weight: bold;">AS</span> 
    <span style="color: #CC00FF;">Aggregate</span>
    <span style="color: #003300; font-weight: bold;">&#40;</span><span style="color: #333333;">[Time]</span>.<span style="color: #333333;">[Calendar Date]</span>.<span style="color: #AF0000;">LastChild</span><span style="color: #66cc66;">:</span><span style="color: #333333;">[Time]</span>.<span style="color: #333333;">[Calendar Date]</span>.<span style="color: #AF0000;">LastChild</span>.<span style="color: #AF0000;">Lag</span><span style="color: #003300; font-weight: bold;">&#40;</span><span style="color: #cc66cc;">6</span><span style="color: #003300; font-weight: bold;">&#41;</span>
     <span style="color: #66cc66;">,</span><span style="color: #333333;">[Measures]</span>.<span style="color: #333333;">[Revenue]</span><span style="color: #003300; font-weight: bold;">&#41;</span>
&nbsp;
  <span style="color: #0000FF; font-weight: bold;">MEMBER</span> <span style="color: #333333;">[Measures]</span>.<span style="color: #333333;">[Previous Week]</span> <span style="color: #0000FF; font-weight: bold;">AS</span> 
     <span style="color: #CC00FF;">Aggregate</span><span style="color: #003300; font-weight: bold;">&#40;</span><span style="color: #333333;">[Time]</span>.<span style="color: #333333;">[Calendar Date]</span>.<span style="color: #AF0000;">LastChild</span>.<span style="color: #AF0000;">Lag</span><span style="color: #003300; font-weight: bold;">&#40;</span><span style="color: #cc66cc;">7</span><span style="color: #003300; font-weight: bold;">&#41;</span>
     <span style="color: #66cc66;">:</span>
     <span style="color: #333333;">[Time]</span>.<span style="color: #333333;">[Calendar Date]</span>.<span style="color: #AF0000;">LastChild</span>.<span style="color: #AF0000;">Lag</span><span style="color: #003300; font-weight: bold;">&#40;</span><span style="color: #cc66cc;">13</span><span style="color: #003300; font-weight: bold;">&#41;</span>
     <span style="color: #66cc66;">,</span><span style="color: #333333;">[Measures]</span>.<span style="color: #333333;">[Revenue]</span><span style="color: #003300; font-weight: bold;">&#41;</span>
<span style="color: #0000FF; font-weight: bold;">SELECT</span> 
  <span style="color: #0000FF; font-weight: bold;">NON</span> <span style="color: #0000FF; font-weight: bold;">EMPTY</span> 
    <span style="color: #003300; font-weight: bold;">&#123;</span><span style="color: #333333;">[Measures]</span>.<span style="color: #333333;">[Previous Week]</span><span style="color: #66cc66;">,</span> <span style="color: #333333;">[Measures]</span>.<span style="color: #333333;">[This Week]</span><span style="color: #003300; font-weight: bold;">&#125;</span> <span style="color: #0000FF; font-weight: bold;">ON</span> <span style="color: #cc66cc;">0</span>
 <span style="color: #66cc66;">,</span><span style="color: #0000FF; font-weight: bold;">NON</span> <span style="color: #0000FF; font-weight: bold;">EMPTY</span> 
    <span style="color: #003300; font-weight: bold;">&#123;</span> 
        <span style="color: #333333;">[Time]</span>.<span style="color: #333333;">[Date Time]</span>.<span style="color: #333333;">[Date Time]</span>.<span style="color: #0000FF;">MEMBERS</span> 
        <span style="color: #66cc66;">*</span> 
        <span style="color: #333333;">[Time]</span>.<span style="color: #333333;">[24 Hour]</span>.<span style="color: #333333;">[24 Hour]</span>.<span style="color: #0000FF;">ALLMEMBERS</span>
    <span style="color: #003300; font-weight: bold;">&#125;</span> <span style="color: #0000FF; font-weight: bold;">ON</span> <span style="color: #cc66cc;">1</span>
<span style="color: #0000FF; font-weight: bold;">FROM</span> 
<span style="color: #003300; font-weight: bold;">&#40;</span>
  <span style="color: #0000FF; font-weight: bold;">SELECT</span> 
    <span style="color: #0000FF;">Tail</span><span style="color: #003300; font-weight: bold;">&#40;</span>
         <span style="color: #0000FF;">Filter</span><span style="color: #003300; font-weight: bold;">&#40;</span>
               <span style="color: #333333;">[Time]</span>.<span style="color: #333333;">[24 Hour]</span>.<span style="color: #333333;">[24 Hour]</span>.<span style="color: #0000FF;">MEMBERS</span>
               <span style="color: #66cc66;">,</span><span style="color: #CC00FF;">Sum</span><span style="color: #003300; font-weight: bold;">&#40;</span><span style="color: #333333;">[Time]</span>.<span style="color: #333333;">[Calendar Date]</span>.<span style="color: #AF0000;">LastChild</span><span style="color: #66cc66;">,</span><span style="color: #333333;">[Measures]</span>.<span style="color: #333333;">[Revenue]</span><span style="color: #003300; font-weight: bold;">&#41;</span> <span style="color: #66cc66;">&gt;</span> <span style="color: #cc66cc;">0</span>
         <span style="color: #003300; font-weight: bold;">&#41;</span><span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">1</span>
    <span style="color: #003300; font-weight: bold;">&#41;</span> <span style="color: #0000FF; font-weight: bold;">ON</span> <span style="color: #cc66cc;">0</span>
  <span style="color: #0000FF; font-weight: bold;">FROM</span> 
  <span style="color: #003300; font-weight: bold;">&#40;</span><span style="color: #0000FF; font-weight: bold;">SELECT</span> 
      <span style="color: #003300; font-weight: bold;">&#123;</span>
            <span style="color: #333333;">[Time]</span>.<span style="color: #333333;">[Calendar Date]</span>.<span style="color: #AF0000;">LastChild</span>
            <span style="color: #66cc66;">:</span>
            <span style="color: #333333;">[Time]</span>.<span style="color: #333333;">[Calendar Date]</span>.<span style="color: #AF0000;">LastChild</span>.<span style="color: #AF0000;">Lag</span><span style="color: #003300; font-weight: bold;">&#40;</span><span style="color: #cc66cc;">13</span><span style="color: #003300; font-weight: bold;">&#41;</span>
      <span style="color: #003300; font-weight: bold;">&#125;</span> <span style="color: #0000FF; font-weight: bold;">ON</span> <span style="color: #cc66cc;">0</span>
    <span style="color: #0000FF; font-weight: bold;">FROM</span> <span style="color: #333333;">[Cube]</span>
  <span style="color: #003300; font-weight: bold;">&#41;</span>
<span style="color: #003300; font-weight: bold;">&#41;</span></pre></div></div>

<p>And to top it all off - after seeing the chart for a while, nobody liked it (after all, it's a relatively abstract view of revenue) and we dumped it.  <img src='http://timlaqua.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://timlaqua.com/2009/02/wierd-slice-revenue-for-the-most-recent-hour-in-the-cube-across-the-last-seven-days/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to add a calculated measure (calculated field) to an Excel 2007 PivotTable with a SSAS data source</title>
		<link>http://timlaqua.com/2008/11/how-to-add-a-calculated-measure-calculated-field-to-an-excel-2007-pivottable-with-a-ssas-data-source/</link>
		<comments>http://timlaqua.com/2008/11/how-to-add-a-calculated-measure-calculated-field-to-an-excel-2007-pivottable-with-a-ssas-data-source/#comments</comments>
		<pubDate>Wed, 05 Nov 2008 18:28:12 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[How-to Guides]]></category>
		<category><![CDATA[Scripts & Code]]></category>
		<category><![CDATA[calculated measure]]></category>
		<category><![CDATA[calculated member]]></category>
		<category><![CDATA[excel]]></category>
		<category><![CDATA[excel 2007]]></category>
		<category><![CDATA[named set]]></category>
		<category><![CDATA[pivottable]]></category>
		<category><![CDATA[ssas]]></category>

		<guid isPermaLink="false">http://timlaqua.com/?p=50</guid>
		<description><![CDATA[As it turns out, you can do it programatically as explained by Allan Folting here: Microsoft Excel: Common Questions Around Excel 2007 OLAP PivotTables: http://blogs.msdn.com/excel/archive/2008/02/05/common-questions-around-excel-2007-OLAP-PivotTables.aspx And the parts that I have to keep looking up (I use my blog as a notebook for things I don't want to forget : Sub AddCalculatedMeasure() Dim pvt As [...]]]></description>
			<content:encoded><![CDATA[<p>As it turns out, you can do it programatically as explained by <strong>Allan Folting </strong>here:<br />
<strong>Microsoft Excel: Common Questions Around Excel 2007 OLAP PivotTables</strong>:<br />
<a href="http://blogs.msdn.com/excel/archive/2008/02/05/common-questions-around-excel-2007-OLAP-PivotTables.aspx">http://blogs.msdn.com/excel/archive/2008/02/05/common-questions-around-excel-2007-OLAP-PivotTables.aspx</a></p>
<p>And the parts that I have to keep looking up (I use my blog as a notebook for things I don't want to forget <img src='http://timlaqua.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> :</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Sub</span> AddCalculatedMeasure() 
	<span style="color: #000080;">Dim</span> pvt <span style="color: #000080;">As</span> PivotTable
	<span style="color: #000080;">Dim</span> strName <span style="color: #000080;">As</span> <span style="color: #000080;">String</span>
	<span style="color: #000080;">Dim</span> strFormula <span style="color: #000080;">As</span> <span style="color: #000080;">String</span> 
&nbsp;
	<span style="color: #000080;">Set</span> pvt = Sheet1.PivotTables(&quot;PivotTable1&quot;)
	strName = &quot;[Measures].[Internet Sales Amount 25 %]&quot;
	strFormula = &quot;[Measures].[Internet Sales Amount]*1.25&quot;
	pvt.CalculatedMembers.Add Name:=strName, Formula:=strFormula, <span style="color: #000080;">Type</span>:=xlCalculatedMember 
<span style="color: #000080;">End</span> <span style="color: #000080;">Sub</span> 
&nbsp;
<span style="color: #000080;">Sub</span> AddCalculatedMember() 
	<span style="color: #000080;">Dim</span> pvt <span style="color: #000080;">As</span> PivotTable
	<span style="color: #000080;">Dim</span> strName <span style="color: #000080;">As</span> <span style="color: #000080;">String</span>
	<span style="color: #000080;">Dim</span> strFormula <span style="color: #000080;">As</span> <span style="color: #000080;">String</span> 
&nbsp;
	<span style="color: #000080;">Set</span> pvt = Sheet1.PivotTables(&quot;PivotTable1&quot;)
	strName = &quot;[Product].[Product Categories].[Bikes].[Mountain Bikes].[Mountain-100 Silver, 38 25 %]&quot;
	strFormula = &quot;[Product].[Product Categories].[Bikes].[Mountain Bikes].[Mountain-100 Silver, 38]*1.25&quot;
	pvt.CalculatedMembers.Add Name:=strName, Formula:=strFormula, <span style="color: #000080;">Type</span>:=xlCalculatedMember
	pvt.ViewCalculatedMembers = <span style="color: #000080;">True</span> 
<span style="color: #000080;">End</span> <span style="color: #000080;">Sub</span> 
&nbsp;
<span style="color: #000080;">Sub</span> AddNamedSet() 
	<span style="color: #000080;">Dim</span> pvt <span style="color: #000080;">As</span> PivotTable
	<span style="color: #000080;">Dim</span> strName <span style="color: #000080;">As</span> <span style="color: #000080;">String</span>
	<span style="color: #000080;">Dim</span> strFormula <span style="color: #000080;">As</span> <span style="color: #000080;">String</span>
	<span style="color: #000080;">Dim</span> cbf <span style="color: #000080;">As</span> CubeField 
&nbsp;
	<span style="color: #000080;">Set</span> pvt = Sheet1.PivotTables(&quot;PivotTable1&quot;)
	strName = &quot;[My Mountain Bikes]&quot;
	strFormula = &quot;[Product].[Product Categories].[Bikes].[Mountain Bikes].children&quot;
	pvt.CalculatedMembers.Add Name:=strName, Formula:=strFormula, <span style="color: #000080;">Type</span>:=xlCalculatedSet
	<span style="color: #000080;">Set</span> cbf = pvt.CubeFields.AddSet(Name:=&quot;[My Mountain Bikes]&quot;, Caption:=&quot;Mountain Bikes&quot;) 
<span style="color: #000080;">End</span> <span style="color: #000080;">Sub</span></pre></div></div>

<p>He also mentions that you can expose these members to Excel Services 2007 by creating the new objects and then removing the VBA code - very useful article.</p>
]]></content:encoded>
			<wfw:commentRss>http://timlaqua.com/2008/11/how-to-add-a-calculated-measure-calculated-field-to-an-excel-2007-pivottable-with-a-ssas-data-source/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

