Custom Sorting using Microsoft.AnalysisServices to generate an OLAP Cube











up vote
0
down vote

favorite












In this project we are dynamically creating a multidimensional cube via Microsoft.AnalysisServices in VB.NET. This code has been used for a few years and now we need to make a modification.



We add a fact table with a field D1.
We then add an assortment of master tables, including D1 and the relationships. So we programatically adding relations for D1 with something like:



DataSourceView.Schema.Relations.Add(pkColumn, fkColumn)


We the add the dimension D1 and define the Key/Name:



Private Function GenerateAttributeDimensionGeneric(ByVal objDatabase As Database, ByVal objDataSourceView As DataSourceView) As Object        
Dim objDimension As New Dimension()
objDimension = objDatabase.Dimensions.Add("D1")
objDimension.Source = New DataSourceViewBinding(objDataSourceView.ID)
Dim objDimensionAttributesColl As DimensionAttributeCollection = objDimension.Attributes

Dim objAttribute As DimensionAttribute = objDimensionAttributesColl.Add("D1_PK")
objAttribute.Usage = AttributeUsage.Key
objAttribute.KeyColumns.Add("D1", "D1_PK", OleDbType.[Integer])
objAttribute.NameColumn = New DataItem("D1", "AttributeValueName")


This works dandy. Now we are being requested to add custom sorting options on D1. So we added a new field (iOrder) to the schema and changed the import to include this for the D1 table.



When adding the Dimension D1 using the code snippet above, I'm trying to tell it to use iOrder.



objAttribute.AttributeRelationships.Add("iOrder")
objAttribute.OrderBy = OrderBy.AttributeName
objAttribute.OrderByAttribute.Name = "iOrder"


after the last row I'm getting an error.




Object reference not set to an instance of an object.




Anyone have thoughts or examples of custom ordering USING C#/VB.NET? was utilizing this to get me this far.










share|improve this question




























    up vote
    0
    down vote

    favorite












    In this project we are dynamically creating a multidimensional cube via Microsoft.AnalysisServices in VB.NET. This code has been used for a few years and now we need to make a modification.



    We add a fact table with a field D1.
    We then add an assortment of master tables, including D1 and the relationships. So we programatically adding relations for D1 with something like:



    DataSourceView.Schema.Relations.Add(pkColumn, fkColumn)


    We the add the dimension D1 and define the Key/Name:



    Private Function GenerateAttributeDimensionGeneric(ByVal objDatabase As Database, ByVal objDataSourceView As DataSourceView) As Object        
    Dim objDimension As New Dimension()
    objDimension = objDatabase.Dimensions.Add("D1")
    objDimension.Source = New DataSourceViewBinding(objDataSourceView.ID)
    Dim objDimensionAttributesColl As DimensionAttributeCollection = objDimension.Attributes

    Dim objAttribute As DimensionAttribute = objDimensionAttributesColl.Add("D1_PK")
    objAttribute.Usage = AttributeUsage.Key
    objAttribute.KeyColumns.Add("D1", "D1_PK", OleDbType.[Integer])
    objAttribute.NameColumn = New DataItem("D1", "AttributeValueName")


    This works dandy. Now we are being requested to add custom sorting options on D1. So we added a new field (iOrder) to the schema and changed the import to include this for the D1 table.



    When adding the Dimension D1 using the code snippet above, I'm trying to tell it to use iOrder.



    objAttribute.AttributeRelationships.Add("iOrder")
    objAttribute.OrderBy = OrderBy.AttributeName
    objAttribute.OrderByAttribute.Name = "iOrder"


    after the last row I'm getting an error.




    Object reference not set to an instance of an object.




    Anyone have thoughts or examples of custom ordering USING C#/VB.NET? was utilizing this to get me this far.










    share|improve this question


























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      In this project we are dynamically creating a multidimensional cube via Microsoft.AnalysisServices in VB.NET. This code has been used for a few years and now we need to make a modification.



      We add a fact table with a field D1.
      We then add an assortment of master tables, including D1 and the relationships. So we programatically adding relations for D1 with something like:



      DataSourceView.Schema.Relations.Add(pkColumn, fkColumn)


      We the add the dimension D1 and define the Key/Name:



      Private Function GenerateAttributeDimensionGeneric(ByVal objDatabase As Database, ByVal objDataSourceView As DataSourceView) As Object        
      Dim objDimension As New Dimension()
      objDimension = objDatabase.Dimensions.Add("D1")
      objDimension.Source = New DataSourceViewBinding(objDataSourceView.ID)
      Dim objDimensionAttributesColl As DimensionAttributeCollection = objDimension.Attributes

      Dim objAttribute As DimensionAttribute = objDimensionAttributesColl.Add("D1_PK")
      objAttribute.Usage = AttributeUsage.Key
      objAttribute.KeyColumns.Add("D1", "D1_PK", OleDbType.[Integer])
      objAttribute.NameColumn = New DataItem("D1", "AttributeValueName")


      This works dandy. Now we are being requested to add custom sorting options on D1. So we added a new field (iOrder) to the schema and changed the import to include this for the D1 table.



      When adding the Dimension D1 using the code snippet above, I'm trying to tell it to use iOrder.



      objAttribute.AttributeRelationships.Add("iOrder")
      objAttribute.OrderBy = OrderBy.AttributeName
      objAttribute.OrderByAttribute.Name = "iOrder"


      after the last row I'm getting an error.




      Object reference not set to an instance of an object.




      Anyone have thoughts or examples of custom ordering USING C#/VB.NET? was utilizing this to get me this far.










      share|improve this question















      In this project we are dynamically creating a multidimensional cube via Microsoft.AnalysisServices in VB.NET. This code has been used for a few years and now we need to make a modification.



      We add a fact table with a field D1.
      We then add an assortment of master tables, including D1 and the relationships. So we programatically adding relations for D1 with something like:



      DataSourceView.Schema.Relations.Add(pkColumn, fkColumn)


      We the add the dimension D1 and define the Key/Name:



      Private Function GenerateAttributeDimensionGeneric(ByVal objDatabase As Database, ByVal objDataSourceView As DataSourceView) As Object        
      Dim objDimension As New Dimension()
      objDimension = objDatabase.Dimensions.Add("D1")
      objDimension.Source = New DataSourceViewBinding(objDataSourceView.ID)
      Dim objDimensionAttributesColl As DimensionAttributeCollection = objDimension.Attributes

      Dim objAttribute As DimensionAttribute = objDimensionAttributesColl.Add("D1_PK")
      objAttribute.Usage = AttributeUsage.Key
      objAttribute.KeyColumns.Add("D1", "D1_PK", OleDbType.[Integer])
      objAttribute.NameColumn = New DataItem("D1", "AttributeValueName")


      This works dandy. Now we are being requested to add custom sorting options on D1. So we added a new field (iOrder) to the schema and changed the import to include this for the D1 table.



      When adding the Dimension D1 using the code snippet above, I'm trying to tell it to use iOrder.



      objAttribute.AttributeRelationships.Add("iOrder")
      objAttribute.OrderBy = OrderBy.AttributeName
      objAttribute.OrderByAttribute.Name = "iOrder"


      after the last row I'm getting an error.




      Object reference not set to an instance of an object.




      Anyone have thoughts or examples of custom ordering USING C#/VB.NET? was utilizing this to get me this far.







      .net vb.net ssas olap ssas-2012






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 8 at 16:57









      Al Fahad

      755621




      755621










      asked Nov 8 at 16:33









      user1272386

      19110




      19110





























          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














           

          draft saved


          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53212117%2fcustom-sorting-using-microsoft-analysisservices-to-generate-an-olap-cube%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown






























          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53212117%2fcustom-sorting-using-microsoft-analysisservices-to-generate-an-olap-cube%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Schultheiß

          Verwaltungsgliederung Dänemarks

          Liste der Kulturdenkmale in Wilsdruff