<?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; named set</title>
	<atom:link href="http://timlaqua.com/tag/named-set/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>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>

