Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

admill1519
New Contributor II

.net sdk how to get values of fields inside qlik sense app

Hi,

    I want to access values of fields inside the qlik sense app. Right now, I am getting list of field names but, I also want to access values of the fields. I am using .net SDK. Please help! since I am new to c#, I don't know the advance coding in c#.

1 Solution

Accepted Solutions
Employee
Employee

Re: .net sdk how to get values of fields inside qlik sense app

The NxPage structure defines a rectangle of cells from the table produced by the hypercube. The "Top" and "Left" properties indicates the top left corner of the rectangle, and the "Height" and "Width" properties indicates its size. If you only want the second column you should use the following page (columns are indexes from 0):

new NxPage { Top = 0, Left = 1, Height  = 20, Width = 1 };

17 Replies
Employee
Employee

Re: .net sdk how to get values of fields inside qlik sense app

You should probably check out this method:

AppExtensions.GetAppField Method

There is a small example to look at here:

App fields ‒ Qlik Sense Developers

admill1519
New Contributor II

Re: .net sdk how to get values of fields inside qlik sense app

Thanks, but the problem now has been resolved. If you could help me to create barcharts or piechats(or any chart) on the fly by using measures and dimensions using .net sdk that will be great.

Employee
Employee

Re: .net sdk how to get values of fields inside qlik sense app

The ISheet Interface has a number of methods for doing that type of operations. If you open the sheet where you want to add the visualization, then you can use this method to add a basic bar chart:

ISheet.CreateBarchart Method (String, BarchartDataContainer)

Any customization of the bar chart (like choosing orientation or setting colors) would have to be done by modifying the properties of the GenericObject returned by CreateBarchart.

admill1519
New Contributor II

Re: .net sdk how to get values of fields inside qlik sense app

As you know In qlik app there are multiple sheet and each sheet contain multiple objects(bar chart, pie chart or any other type). I am able to get the object ID and I am also able to find out if it is barchart or piechart but I want to access data within that chart(text or chart doesn't matter). how can I achieve that.

Employee
Employee

Re: .net sdk how to get values of fields inside qlik sense app

This page is probably of interest to you: Retrieving data ‒ Qlik Sense Developers

The concept of "hyperubes" is at the core here, since that is the structure used by Qlik Sense to aggregate the data. You should also look into this page, which describes a class provided with the .Net SDK for doing paging across hypercubes (and list objects):

Paging of data ‒ Qlik Sense Developers

Typically, the flow would be something like this:

var obj = app.GetObject<GenericObject>("theid");

var pager = obj.GetAllHypercubePagers().First();

var data = pager.GetData();

Or if you know the object is a bar chart, then you can do like this:

var barchart = app.GetObject<Barchart>("theid");

var data = barchart.HyperCubePager.GetData();

There is also a project available here that further illustrates how to work with hypercubes in the .Net SDK: Qlik Branch

admill1519
New Contributor II

Re: .net sdk how to get values of fields inside qlik sense app

thanks but it is giving me System.Collections.Generic.List`1[Qlik.Engine.NxDataPage]  output when I am printing var data in console. I am not getting data. I was trying 2nd solution.

Employee
Employee

Re: .net sdk how to get values of fields inside qlik sense app

The result returned by GetData is a list of data pages corresponding to the pages requested in the call. Default page set for GetData is a single page containing the first 20 entries. To access the actual value, you would do something like this (Num value used in this case):

var dataPages = pager.GetData();

var numValues = dataPages.First().Matrix.SelectMany(row => row.Select(cell => cell.Num));

admill1519
New Contributor II

Re: .net sdk how to get values of fields inside qlik sense app

thanks I am able to get the numeric values from that chart

var p = new List<NxPage> { new NxPage { Height = 20, Width = 1 } };

can you explain me the above line of code.Correct me if I am wrong, as per my understanding Height == number of rows and width==number of columns. when I change width to 2 it give me two output but I want to get the second output only not both(data of 2nd column)

Employee
Employee

Re: .net sdk how to get values of fields inside qlik sense app

The NxPage structure defines a rectangle of cells from the table produced by the hypercube. The "Top" and "Left" properties indicates the top left corner of the rectangle, and the "Height" and "Width" properties indicates its size. If you only want the second column you should use the following page (columns are indexes from 0):

new NxPage { Top = 0, Left = 1, Height  = 20, Width = 1 };