Qlik Community

Qlik Sense Integration, Extensions, & APIs

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

Not applicable

qMatrix - differences between qNum and qText

Hi all,

i'm developing an extension that shows a kpi and the trend vs a compare value.

so my hyper cube is build with two measures and no dimensions.

this is the response from the server..

issue.png

as you can see there is a difference between the num and the text value in the same cell !!

the text value is correct while the num value equals the value of the second cell ( closed in the image )

???

it is an hyper cube configuration issue or what else?

Loris

1 Solution

Accepted Solutions
Not applicable

Re: qMatrix - differences between qNum and qText

ok, i found the bug..

in the angular directive that i use for showing the kpi there is an arrow that indicates the trend, so when there is a growth it shows an up arrow otherwhise a down arrow...

but i was missing the double equal when checking for no changes... so when it execs kpi1=kpi2 it assigns the value to the second kpi and returns true...

the correct angular expression should be kpi1==kpi2

a newbie error !!

8 Replies
Employee
Employee

Re: qMatrix - differences between qNum and qText

That seems a bit odd, every value in Qlik has a string and a numerical interpretation. You get both of them by using Num() or Text() wrapped around your expression just to verify the numbers in the client. The qNum and qText property maps against the string and numerical value (referred to as a Dual in Qlik).

Since you aren't using any dimensions perhaps you are better off just defining a string or a value expression instead,

https://help.qlik.com/sense/2.0/en-us/developer/Subsystems/Extensions/Content/Overview/generic-objec...

initialProperties : {

     version: 1.0,

     kpi1: {

          qValueExpression: '=Sum(Value)'

     },

     kpi2: {

          qValueExpression: '=Sum(Value2)'

     }
}

This will ensure your expression is evaluated as a numerical value and will be available on the layout object at layout.kpi1 and layout.kpi2

Employee
Employee

Re: qMatrix - differences between qNum and qText

There could of course be rounding errors as qNum is a double precision floating point value but we should not do any computations on the metric client side.

Not applicable

Re: qMatrix - differences between qNum and qText

for sure it is not a rounding error!

maybe i wasn't clear, but the text value equals the text value of the second kpi!

in the first cell only the num value is correct, in the second cell both num and text value are ok!

Employee
Employee

Re: qMatrix - differences between qNum and qText

Ye it's strange, can you paste the definition so we can take a look at it?

Not applicable

Re: qMatrix - differences between qNum and qText

so this is my cube definition:

qHyperCubeDef: {

            qDimensions: [],

            qMeasures: [],

            qInitialDataFetch: [

                {

                    qWidth: 2,

                    qHeight: 1

                }

            ]

        }

and this is the props definitions

define([],function(){"use strict";

   

    var measures={uses:"measures",min:2,max:2};

   

    return{

        type:"items",

        component:"accordion",

        items:{

            measures:measures,

        }

    }

});

Employee
Employee

Re: qMatrix - differences between qNum and qText

Strange indeed, I throw together my own version and tested it against the normal ctrl + 0 + 0 script and it worked as expected, 2measurechart.js · GitHub

2measures.PNG

If you test it with a different set of measures do you get the same results? Have you tried removing the extension from the sheet, reload Qlik Sense desktop and add it back in again just in case there is any old properties settings cached.


I noticed you have a props object on there so there is more to the definition, any other logic that sets something besides static properties?

And if I just do a sum(0.95421095666394) (I have different regional settings for decimals) it will round it but not to the extent that you are seeing,

rounding.PNG

Not applicable

Re: qMatrix - differences between qNum and qText

ok, i found the bug..

in the angular directive that i use for showing the kpi there is an arrow that indicates the trend, so when there is a growth it shows an up arrow otherwhise a down arrow...

but i was missing the double equal when checking for no changes... so when it execs kpi1=kpi2 it assigns the value to the second kpi and returns true...

the correct angular expression should be kpi1==kpi2

a newbie error !!

Employee
Employee

Re: qMatrix - differences between qNum and qText

hehe, good to hear it was not a bug in the api
Make sure you mark the thread as answered so we can keep track of open topics

Community Browser