Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
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
Author

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 !!

View solution in original post

8 Replies
Alexander_Thor
Employee
Employee

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

Alexander_Thor
Employee
Employee

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
Author

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!

Alexander_Thor
Employee
Employee

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

Not applicable
Author

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,

        }

    }

});

Alexander_Thor
Employee
Employee

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
Author

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 !!

Alexander_Thor
Employee
Employee

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