1 Reply Latest reply: Sep 18, 2018 5:30 AM by Morne van Zyl RSS

    qAttributeDimensions/Expressions explanation needed

    Danny Selgo

      Hello, I am trying to figure out the purpose of qAttributeDimensions and qAttributeExpressions when defining the properties of a Hypercube in the Visualization API (https://help.qlik.com/en-US/sense-developer/April2018/Subsystems/EngineAPI/Content/GenericObject/PropertyLevel/HyperCube…). The documentation isn't very clear on this topic.

       

      My current understanding is that it can be used to define the properties of the dimension/expression much like how you could define "Background Color" or "Text Color" in QlikView. I'm just not sure on the syntax for this though.

       

      My end goal is to have a bar chart with multiple measures, and be able to assign a different color to each measure.

        • Re: qAttributeDimensions/Expressions explanation needed
          Morne van Zyl

          I know this is an old question but I thought I'd add a possible solution.

           

          To add an expression to your Measure within the properties panel, you need to create the following definition obj. Note the "items" property within the measure's definition.

          return {
              type: "items",
              component: "accordion",
              items: {
                  dimensions: {
                      uses: "dimensions",
                      min: 1,
                      max: 1
                  },
                  measures: {
                      uses: "measures",
                      min: 1,
                      max: 1,
                      items: {
                          colorBackExpression: {
                              type: "string",
                              label: "Background color expression",
                              ref: "qAttributeExpressions.0.qExpression",
                              component: "expression",
                          },
                          colorTextExpression: {
                              type: "string",
                              label: "Text color expression",
                              ref: "qAttributeExpressions.1.qExpression",
                              component: "expression",
                      }
                  },
                  sorting: {
                      uses: "sorting"
                  },
                  settings: {
                      uses: "settings"
                  }
              }
          }

           

          Then within your paint() function, you will find this result of the expression within the following property qAttrExps.qValues[0].qText of the Measure within the result set returned.

           

          The full path would be something as follows. layout.qHyperCube.qDataPages.qMatrix[0][0].qAttrExps.qValues[0].qText but in most cases, you'd be looping through the dataset so you probably won't require the full path.

           

          You can also find the definition of the expression on the measure within the qMeasureInfo property on the HyperCube.

          layout.qHyperCube.qMeasureInfo[0].qAttrExprInfo[0]

           

          Hope that helps.