5 Replies Latest reply: Mar 31, 2016 3:54 AM by Tobias Åström RSS

    Create Alternative Dimension and Measure using .NET SDK in Qliksense

    prabhu appu

      Hi,

       

      I need a help in creating alternative dimensions and measures for a chart using .NET SDK.

      I have a code to create a bar chart. But I don't know how to mention this in hypercube property. Using Engine API explorer i identified that this property has been defined in "qHyperCubeDef/qLayoutExclude/" (Please refer the attachment)

       

      I don't know how to use this in C#. If anyone can help me on this that would be great.

       

      barChart.Properties.HyperCubeDef = new Qlik.Sense.Client.Visualizations.VisualizationHyperCubeDef
                                  {
                                      //LayoutExclude = ,
                                      Dimensions = QliksenseBar[chart].DimensionDetails,
                                      Measures = QliksenseBar[chart].ExpressionDetails,
                                      SuppressZero = QliksenseBar[chart].SuppressZero,
                                      InterColumnSortOrder = QliksenseBar[chart].SortOrder.ToArray(),
                                      InitialDataFetch = new List<NxPage> { new NxPage { Height = 500, Left = 0, Top = 0, Width = 17 } }.ToArray()
                                  };
      
      
      

      1.PNG

       

      Regards,

      Prabhu Appu

        • Re: Create Alternative Dimension and Measure using .NET SDK in Qliksense
          Øystein Kolsrud

          The property "qLayoutExclude" is being used as a generic container by the client to preserve data that is not a direct part of the visualization. It is therefore not a part of the class structures we provide in the .Net SDK, but it can be accessed with the generic getters and setters of the AbstractStructure class.

           

          You would set the "qLayoutExclude" like this:

           

          IBarchart barChart = <code to open barchart>;

          VisualizationHyperCube myAlternativeCube = <code to construct alternative cube>;

          using (barChart.SuspendedLayout)

          {

            barChart.Properties.HyperCubeDef.Set("qLayoutExclude", myAlternativeCube);

          }

           

          If you want to read the hypercube definition from "qLayoutExclude" then you would write something like this:

           

          var hyperCube = barChart.Propreties.HyperCubeDef;

          var myAlternativeCube = hyperCube.Get<VisualizationHyperCube>("qLayoutExclude");

            • Re: Create Alternative Dimension and Measure using .NET SDK in Qliksense
              prabhu appu

              Hi Øystein Kolsrud,

               

              Thanks for your reply. I tried creating a alternate dimension in one of the existing chart and try to get it using .net SDK.

              below is the code that i'm using,

               

              var data = application
                         .GetSheet("rNDVjKR")
                         .GetBarchart("pbYvEmw").Properties.HyperCubeDef.Get<VisualizationHyperCube>("qLayoutExclude");
              

               

              but i'm getting null as a result.

               

              PFB the both C# and Engine API output

               

              5.PNG

               

              3.PNG

               

              I couldn't set the qLayoutExclude property also


              var myInlineDimension = new HyperCubeDimensionqDef { CId = "NewDimension", FieldDefs = new[] { "Year" }, AutoSort = true };
                                  VisualizationHyperCubeDef AlternateCube = new Qlik.Sense.Client.Visualizations.VisualizationHyperCubeDef
                                  {
                                      Dimensions = new List<HyperCubeDimensionDef>()
                                      {
                                        new HyperCubeDimensionDef(){ Def= myInlineDimension}
                                      }
                                  };
                                  barChart.Properties.HyperCubeDef.Set("qLayoutExclude", AlternateCube);
              


              Am i doing something wrong. Please help to solve this.


              Thanks in advance.


              Regards,

              Prabhu Appu


            • Re: Create Alternative Dimension and Measure using .NET SDK in Qliksense
              Tobias Åström

              Hello,

              Sorry for the late addition but there is currently an issue with alternative dimensions/measures that you should be aware of. When an app is migrated it will clean all alternative dimensions/measures from the charts. This currently happens if you import an app in a server setup or open it in a different desktop version.

               

              We are working on a fix for this issue, but it is currently not clear when it will be released.

              Regards,

              Tobias, Developer Qlik Sense