11 Replies Latest reply: Mar 13, 2018 6:32 AM by Øystein Kolsrud RSS

    How Create a HyperCube in .Net SDK

    Thiago Dutra



      Hello I am developing an app in .Net and would like to access data on Qlik Sense.

      I managed to create the connection to the Qlik Engime however I am unable to create HyperCube and read the results as I do in JavaScript.

      Can anyone help me with some example of HyperCubo creation and your reading?


        • Re: How Create a HyperCube in .Net SDK
          Sangram Reddy

          Hi Thiago,

          Check this out:

          Creating dimensions and measures

          There are two ways of creating Dimensionsand Measures:

          • Locally in the generic object.
          • Added to the application library for reuse in other generic objects.

          Example: Create a local or inline Dimensions

             var myInlineDimension = new HyperCubeDimensionqDef { FieldDefs = new[] { "myDimension" } };

          Example: Create an application or library Dimensions

             var myLibraryDimension = application.CreateDimension(); myLibraryDimension.SuspendLayout(); myLibraryDimension.Properties.Dim.FieldDefs = new[] {"myDimension"}; myLibraryDimension.ResumeLayout();

          Example: Create a local or inline measure

             var myInlineMeasure = new HyperCubeMeasureqDef {Def = "=Sum(value)"};

          Example: Create an application or library Measures

             var myLibraryMeasure = application.CreateMeasure(); myLibraryMeasure.SuspendLayout(); myLibraryMeasure.Properties.Measure.Def = "=Sum(value)"; myLibraryMeasure.ResumeLayout();

          Adding dimensions and measures to the hypercube

          When you have created your Dimensions and Measures you can add them to the hypercube.

          Example: Add a Dimension to the hypercube

            cubeDef.Dimensions = new List<HyperCubeDimensionDef> { new HyperCubeDimensionDef {Def = myInlineDimension}, new HyperCubeDimensionDef {LibraryId = myLibraryDimension.Info.Id} };

          Example: Add a Measures to the hypercube

            cubeDef.Measures = new List<HyperCubeMeasureDef> { new HyperCubeMeasureDef {Def = myInlineMeasure}, new HyperCubeMeasureDef {LibraryId = myLibraryMeasure.Info.Id} };


          Thanks and Regards,

          Sangram Reddy.

          • Re: How Create a HyperCube in .Net SDK
            Thiago Dutra

            Thanks for the help, I can now read the hypercube data and my development is complete



            Thanks for all the help.

            • Re: How Create a HyperCube in .Net SDK
              Tomohiro Takahashi


              Please take a look at my tweet.

              [How to create HyperCube object via Qlik Sense Engine Service(QES) with Qlik Sense .NET SDK]



              [Sample Code]


                    var myDimension = new HyperCubeDimensionqDef
                      FieldDefs = new[] { "Country" }
                    var myMeasure = new HyperCubeMeasureqDef
                      Def = "Sum([Sales Amount]) / Sum([Budget Amount])"
                    HyperCubeDef myCubeDef = new HyperCubeDef();
                    myCubeDef.Dimensions = new List<HyperCubeDimensionDef> {
                      new HyperCubeDimensionDef {Def = myDimension}
                    myCubeDef.Measures = new List<HyperCubeMeasureDef> {
                      new HyperCubeMeasureDef {Def = myMeasure}
                    myCubeDef.InitialDataFetch = new List<NxPage> {
                      new NxPage {Height=20, Width=5}

                    GenericObjectProperties gp = new GenericObjectProperties();
                    gp.Info = new NxInfo();
                    gp.Info.Type = "hypercube";
                    gp.Set<HyperCubeDef>("qHyperCubeDef", myCubeDef);
                    GenericObject obj = app.CreateGenericSessionObject(gp);