Qlik Community

Qlik Sense Integration, Extensions, & APIs

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

jerryhelms2017
New Contributor

Mashup to retrieve values from a single row straight table

I am writing a mashup that needs to retrieve two values from a single row straight table, as illustrated below.  In one variable I would want the value 22333 and in the second variable 33222.

st.PNG

What is the JS to accomplish this?

Tags (1)
7 Replies
MVP
MVP

Re: Mashup to retrieve values from a single row straight table

You can calculate the two values directly with two variables without using Javascript at all.

You'll have to make use of the Aggr function which can help you grouping over the necessary dimensions and the first parameter will be the expression with an aggregation function that you want to calculate:

vVariableA=Aggr( Sum( {<Year={2017},Country={'Tinystan'}>} Something ) , Year , Country )

jerryhelms2017
New Contributor

Re: Mashup to retrieve values from a single row straight table

I am looking for a mashup solution to retrieve the data points.  The straight table will incorporate any needed aggregations.  The standard mashup solution to retrieve the visualization object is similar to the Js code shown below.  Rather than retrieving the object, I want to retrieve the values in the straight table.

var app = qlik.openApp('50fa200c-9d3b-4048-ac1e-573af8cdd11f', config);

//get objects -- inserted here --

app.getObject('QV04','xwjwJm');

app.getObject('QV03','XYThZn');

app.getObject('QV02','vpFgFAg');

app.getObject('QV01','phfXmU');

erik_wetterberg
Valued Contributor III

Re: Mashup to retrieve values from a single row straight table

Hi,

You could use the createCube method in the API. I assume there are som formulas behind the values in your example, just provide them as measures and you will get a small hypercube back with the actual values.

Erik Wetterberg

https://extendingqlik.upper88.com/

Erik Wetterberg
https://extendingqlik.upper88.com/
jerryhelms2017
New Contributor

Re: Mashup to retrieve values from a single row straight table

The following code retrieves the object model.

var app = qlik.openApp('e968b99c-595f-4106-8e78-9498b96ddd6e', config);

//get objects -- inserted here --

app.getObject('QV01','RMgxzbF').then(model => {

  console.log('a: ',model.layout.qHyperCube.qSize);

 

  model.getHyperCubeData('/qHyperCubeDef', [{

    qTop: 0,

qLeft: 0,

qwidth: 2,

qHeight: 10

  }]).then(data => console.log('b: ',data))

});

I can see the data points in the console.  How do I retrieve the  data points to two different variables?

console.PNG

erik_wetterberg
Valued Contributor III

Re: Mashup to retrieve values from a single row straight table

HI,

something like:

var row = data[0].qMatrix[0];

var x1 = row[0].qNum;

etc....

Erik

Erik Wetterberg
https://extendingqlik.upper88.com/
jerryhelms2017
New Contributor

Re: Mashup to retrieve values from a single row straight table

Thank you very much for your help.  I am pretty new to Javascript and it is not clear to me where I would place your suggested code to retrieve the values.

Highlighted
erik_wetterberg
Valued Contributor III

Re: Mashup to retrieve values from a single row straight table

Try the place where you log the data today.

Erik Wetterberg
https://extendingqlik.upper88.com/
Community Browser