Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
jerryhelms2017
Partner - Contributor III
Partner - Contributor III

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?

8 Replies
petter
Partner - Champion III
Partner - Champion III

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
Partner - Contributor III
Partner - Contributor III
Author

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

ErikWetterberg

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/

jerryhelms2017
Partner - Contributor III
Partner - Contributor III
Author

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

ErikWetterberg

HI,

something like:

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

var x1 = row[0].qNum;

etc....

Erik

jerryhelms2017
Partner - Contributor III
Partner - Contributor III
Author

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.

dannyy81
Contributor III
Contributor III

you could use  variable.setStringValue method to assign value into script variable :

app.variable.setStringValue("variable", value);