Qlik Community

Qlik Sense Integration, Extensions, & APIs

Discussion board where members can learn more about Integration, Extensions and API’s for Qlik Sense.

prabhuappu
Contributor II

Create Alternative Dimension and Measure using .NET SDK in Qliksense

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

Tags (3)
1 Solution

Accepted Solutions
Highlighted
Employee
Employee

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

Sorry, I missed a level in my property path there, and I also just realized that the LayoutExclude property is in fact available as a C# property for the VisualizationHyperCubeDef class. You should probably write like this:

var data = application.

  GetSheet("rNDVjKR").GetBarchart("pbYvEmw").Properties.HyperCubeDef.LayoutExclude.

  Get<VisualizationHyperCubeDef>("qHyperCubeDef");

5 Replies
Employee
Employee

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

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");

prabhuappu
Contributor II

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

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


Highlighted
Employee
Employee

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

Sorry, I missed a level in my property path there, and I also just realized that the LayoutExclude property is in fact available as a C# property for the VisualizationHyperCubeDef class. You should probably write like this:

var data = application.

  GetSheet("rNDVjKR").GetBarchart("pbYvEmw").Properties.HyperCubeDef.LayoutExclude.

  Get<VisualizationHyperCubeDef>("qHyperCubeDef");

Employee
Employee

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

And to set your "AlternateCube" you would do like this:

barChart.Properties.HyperCubeDef.LayoutExclude.Set("qHyperCubeDef", AlternateCube);

tsm
New Contributor III

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

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