Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to add library measures to table visualisation on the fly?

I am experimenting with mash ups and trying out the visualisation on the fly. When I try to create a table with a library measure I can't get it to work. It works with library dimensions but not with library measures.

table properties ‒ Qlik Sense

The example in the help gives a columns array as option, but the properites above lists a qHyperCubeDef.

This work

app.visualization.create( 'table', [ "Case Owner Group",

          { "qDef" : { "qDef" : "Avg([Case Duration Time])",

               "qLabel" : "Avg Case Duration Time" }, },

          { "qDef" : { "qDef" : "Sum( [Open Cases] )",

               "qLabel" : "Open Cases" } } ],

{"title" : "Case Owner Group Case stats"} ).then( function ( visual ) { visual.show( 'QV01' ); } );

This doesn't work

app.visualization.create( 'table',

[

  {qDef: {qFieldDefs: ["Employee Status"], "qFieldLabels":["Status"]},

  qNullSuppression: true},

  {

     "qLibraryId": "vpjnFZ",

     "qDef": {

         "qTags": [],

         "qGrouping": "N",

         "qNumFormat": {

             "qType": "U",

             "qnDec": 10,

             "qUseThou": 0

         },

         "qAggrFunc": "Expr",

         "qAccumulate": 0,

         "qActiveExpression": 0,

         "qExpressions": [],

         "autoSort": true,

         "cId": "wfNgj",

         "numFormatFromTemplate": true,

         "textAlign": {

             "auto": true,

             "align": "left"

         }

     },

     "qSortBy": {

         "qSortByNumeric": -1,

         "qSortByLoadOrder": 1,

         "qExpression": {}

     },

     "qAttributeExpressions": [

         {},

         {}

     ],

     "qCalcCond": {}

  }

  ]

,

{"title" : "Case Owner Group Case stats"} ).then( function ( visual ) { visual.show( 'QV01' ); } );

Any ideas?

1 Solution

Accepted Solutions
ErikWetterberg

Hi Karl,

To use a measure from the library you need to specify that it is a measure by adding qTyp: "measure", something like this:

qLibraryId: "vpjnFz",

qType: "measure"

Hope this helps

Erik

View solution in original post

3 Replies
Not applicable
Author

When I try this I get this error.

app.obj.app.visualization.get('sKrVkv').then(function(visual){

  visual.setOptions( { "qHyperCubeDef": { "qDimensions":[{"qDef": {"qFieldDefs": ["Employee Status"],

            "qFieldLabels":["Status"]}

             }],

            "qMeasures":[] },

  "title":"Now improved"

  });

  visual.show( 'table' );

  });

"Patch value not on valid JSON format."

When I remove the fieldDef and label I don't get the error. The title shows "Now improved", and the visualization is incomplete.

app.obj.app.visualization.get('sKrVkv').then(function(visual){

  visual.setOptions( { "qHyperCubeDef": { "qDimensions":[{"qDef": {"qFieldDefs": [],

            "qFieldLabels":[]}

             }],

            "qMeasures":[] },

  "title":"Now improved"

  });

  visual.show( 'table' );

  });

ErikWetterberg

Hi Karl,

To use a measure from the library you need to specify that it is a measure by adding qTyp: "measure", something like this:

qLibraryId: "vpjnFz",

qType: "measure"

Hope this helps

Erik

Not applicable
Author

Thank you Erik! It works!

Is the default qType "dimension", and that's the reason it's not need for dimension?

I downloaded your mashup on Qlik Branch‌ and it was a great resource for handling the basic stuff.