3 Replies Latest reply: Mar 23, 2018 12:54 AM by Humeshkumar Sindpure RSS

    Extension - Custom Attributes for NxDimension

    Patric Amatulli

      Hi,

       

      we are developing our extension and we would like to define custom attributes on dimensions and measures.

      We saw that we have the so called qAttributeExpression property for our NxDimension object, but we do not know how is the correct syntax for our definition file.

       

      qAttributeExpression

      List of attribute expressions.

      Array of NxAttrExprDef

       

      For the measure there exists the qAttributeExpressions Property on the NxMeasure object and it works fine as follow:

       

       

      measures : {

        uses : "measures",

        min : 1,

        items: {

              Dummy: {

                   type: "string",

                   ref: "qAttributeExpressions.0.qExpression",

                   label: "Low Error Value",

                   expression: "always",

                   defaultValue: ""

              }

        }

        },

       

      We tried various version but neither of then works for the Dimension`!

      i.e.

       

       

      dimensions : {

        uses : "dimensions",

        min : 1,

        items: {

          Test: {

              type: "string",

              ref: "qAttributeExpression.0.qExpression",

              label: "test",

              expression: "always",

              defaultValue: ""

                            }

        }

        },

       

       

       

      How is the approach for the dimensions, can somebody assist please.

      We would like to progress with the development of the extension and we get stuck on this point!

       

      Update 26.09.2016:

      Attached an example of what we would like to achieve, based on the Qliksense standard table chart.
      Here we have a row level custom attribute like text color on dimension level.

       

       

      Thanks and regards,

      Patric

        • Re: Extension - Custom Attributes for NxDimension
          Tobias Åström

          Hi there,

          You are basically correct, except that it should be qAttributeExpressions (with the s at the end). The help seems to have this wrong.

           

          The contents of that array is NxAttrExprDef: https://help.qlik.com/en-US/sense-developer/3.0/Subsystems/EngineAPI/Content/Structs/NxAttrExprDef.htm

          Which can contain an simple expression or a libraryID.

           

          so your end result should look something like:

          "qAttributeExpressions": [{

            "qExpression": "Avg([Sales Cost Amount])"

            }],

           

          That should work, but check the resulting dimensionDef if it doesn't.

           

          Best,

          Tobias

          (Sense client dev)

            • Re: Extension - Custom Attributes for NxDimension
              Patric Amatulli

              Thanks Tobias in fact this is what Qlik support told me the last week.

              Your answer is correct, there is a typo in the documentation.

               

              Best,

              Patric

                • Re: Extension - Custom Attributes for NxDimension
                  Humeshkumar Sindpure

                  Hello Sir,

                  I want to add Custome coloe property to dimention.

                   

                   

                  I have written this code inside of dimention shown below:

                   

                  definition : {

                    type : "items",

                    component : "accordion",

                      items : {

                           dimensions : {

                                  uses : "dimensions",

                                  min : 1,

                                  items: {

                                 colorExpression:{

                                                            type: "string",

                                                            label: "Enter color expression",

                                                            ref:"qAttributeExpressions.0.qExpression",

                                                            expression:"optional"

                                                           }

                   

                                   }

                    },

                  now please tell me what should I need to write inside of function

                   

                        paint: function ($element,layout) {

                   

                   

                   

                                        this.backendApi.eachDataRow( function (rownum, row){

                                            var dimIndex = 0; // you are putting the value in your first dimension

                                             row[dimIndex].qAttrExps.qValues[0].qText;

                                        });

                   

                                                if ( !this.$scope.table ) {

                                                this.$scope.table = qlik.table(this);

                   

                                                       }

                   

                                             return qlik.Promise.resolve();

                   

                                 }

                  but Sir , this is not working for me.

                  please give me any solution