Registrations are now open. Join us today!
There is still a lot of work to do on the wiki yet! More information about editing can be found here.
Already have an account?

Difference between revisions of "Microsoft KB Archive/248219"

From BetaArchive Wiki
m (Text replacement - "&" to "&")
m (Text replacement - """ to """)
 
Line 53: Line 53:
 
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. The following example illustrates how to add a calculated member for use with your PivotTable list.
 
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. The following example illustrates how to add a calculated member for use with your PivotTable list.
 
<pre class="codesample"><HTML>
 
<pre class="codesample"><HTML>
<BODY ONLOAD = &quot;Setup_PT()&quot;>
+
<BODY ONLOAD = "Setup_PT()">
  
<OBJECT ID=&quot;PivotControl&quot;
+
<OBJECT ID="PivotControl"
         CLASSID=&quot;CLSID:0002E520-0000-0000-C000-000000000046&quot;
+
         CLASSID="CLSID:0002E520-0000-0000-C000-000000000046"
         style=&quot;HEIGHT: 500px; WIDTH: 500px&quot;>  
+
         style="HEIGHT: 500px; WIDTH: 500px">  
 
</OBJECT>
 
</OBJECT>
  
Line 67: Line 67:
 
       ' source. Replace OLAP_SERVER with the name of your OLAP server or  
 
       ' source. Replace OLAP_SERVER with the name of your OLAP server or  
 
       ' the path to your OLAP cube file.
 
       ' the path to your OLAP cube file.
       strConn = &quot;Provider=MSOLAP.1;Persist Security Info=False;User&quot; & _
+
       strConn = "Provider=MSOLAP.1;Persist Security Info=False;User" & _
                 &quot;ID=sa;Data source=OLAP_SERVER;&quot;Initial Catalog=FoodMart&quot;
+
                 "ID=sa;Data source=OLAP_SERVER;"Initial Catalog=FoodMart"
 
   
 
   
 
       ' Connect the PivotTable list to the OLAP data source.
 
       ' Connect the PivotTable list to the OLAP data source.
 
       PivotControl.ConnectionString = strConn
 
       PivotControl.ConnectionString = strConn
       PivotControl.DataMember = &quot;Sales&quot;
+
       PivotControl.DataMember = "Sales"
 
   
 
   
 
       set conn = PivotControl.Connection
 
       set conn = PivotControl.Connection
Line 79: Line 79:
 
       ' Pass the statement that creates the new calculated member through
 
       ' Pass the statement that creates the new calculated member through
 
       ' the Connection object.
 
       ' the Connection object.
       conn.execute &quot;Create member [Sales].[measures].[Profit per Unit]&quot; _
+
       conn.execute "Create member [Sales].[measures].[Profit per Unit]" _
                   & &quot;as '[measures].[profit] / [measures].[unit sales]'&quot;
+
                   & "as '[measures].[profit] / [measures].[unit sales]'"
 
        
 
        
 
        
 
        
Line 89: Line 89:
 
        
 
        
 
       ' Add the appropriate data to the PivotTable list.
 
       ' Add the appropriate data to the PivotTable list.
       view.RowAxis.InsertFieldSet view.FieldSets(&quot;Promotions&quot;)
+
       view.RowAxis.InsertFieldSet view.FieldSets("Promotions")
       view.DataAxis.InsertTotal view.Totals(&quot;Store Sales&quot;)  
+
       view.DataAxis.InsertTotal view.Totals("Store Sales")  
       view.DataAxis.InsertTotal view.Totals(&quot;Profit&quot;)
+
       view.DataAxis.InsertTotal view.Totals("Profit")
  
 
       ' Add the new calculated member to the PivotTable list.
 
       ' Add the new calculated member to the PivotTable list.
       view.DataAxis.InsertTotal view.Totals(&quot;Profit per Unit&quot;)
+
       view.DataAxis.InsertTotal view.Totals("Profit per Unit")
 
     End Sub
 
     End Sub
 
</SCRIPT>
 
</SCRIPT>

Latest revision as of 13:50, 21 July 2020

Knowledge Base


OFF2000: How to Create a New Calculated Member for the Current PivotTable Session

Article ID: 248219

Article Last Modified on 10/11/2006



APPLIES TO

  • Microsoft Office PivotTable Component 9.0, run time



This article was previously published under Q248219

SUMMARY

The Microsoft Office PivotTable Component that is included with Microsoft Office 2000 Service Release 1 (SR-1) introduces the ability to create a new calculated member when your data source is an Online Analytical Processing (OLAP) server or cube. This article contains sample VB Script code that illustrates how to create a new calculated member for use with the current session of the PivotTable list.

MORE INFORMATION

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. The following example illustrates how to add a calculated member for use with your PivotTable list.

<HTML>
<BODY ONLOAD = "Setup_PT()">

<OBJECT ID="PivotControl" 
        CLASSID="CLSID:0002E520-0000-0000-C000-000000000046"
        style="HEIGHT: 500px; WIDTH: 500px"> 
</OBJECT>

<SCRIPT language=VBScript>
 
    Sub Setup_PT()

       ' Specify the information necessary to connect to the OLAP data 
       ' source. Replace OLAP_SERVER with the name of your OLAP server or 
       ' the path to your OLAP cube file.
       strConn = "Provider=MSOLAP.1;Persist Security Info=False;User" & _
                 "ID=sa;Data source=OLAP_SERVER;"Initial Catalog=FoodMart"
 
       ' Connect the PivotTable list to the OLAP data source.
       PivotControl.ConnectionString = strConn
       PivotControl.DataMember = "Sales"
 
       set conn = PivotControl.Connection
       Set view = PivotControl.ActiveView
      
       ' Pass the statement that creates the new calculated member through
       ' the Connection object.
       conn.execute "Create member [Sales].[measures].[Profit per Unit]" _
                  & "as '[measures].[profit] / [measures].[unit sales]'"
      
      
       ' The following two lines of code are necessary to add the new 
       ' calculated member to the PivotTable list.  
       PivotControl.Refresh
       set data=PivotControl.ActiveData
       
       ' Add the appropriate data to the PivotTable list.
       view.RowAxis.InsertFieldSet view.FieldSets("Promotions")
       view.DataAxis.InsertTotal view.Totals("Store Sales") 
       view.DataAxis.InsertTotal view.Totals("Profit")

       ' Add the new calculated member to the PivotTable list.
       view.DataAxis.InsertTotal view.Totals("Profit per Unit")
    End Sub
</SCRIPT>

</BODY>
</HTML>
                

REFERENCES

For more information about Online Analytical Processing (OLAP), click Microsoft Excel Help on the Help menu, type OLAP in the Office Assistant or the Answer Wizard, and then click Search to view the topics returned.



Additional query words: OFF2000 pivotlist tensor mdx olap

Keywords: kbfix kbhowto KB248219