Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Not applicable

Is it possible to access a meassure or dimension value from the function?

Hy there

I've create a meassure with he name Success Rate Data with the function:

count(if(tcdatasuccess = 'OK',tcdatasuccess))/

(count(if(tcdatasuccess = 'OK',tcdatasuccess))+count(if(tcdatasuccess = 'NOK',tcdatasuccess)))

In my Qlik Sense project I'm using a polygon Map. The fieldmap is the iso code and in the function I've to make several calculation where I've to use the code several times. I didn't found out, how I can access the meassure field.

Isn't it possible to access a meassure or dimension field directly in the formula field?

map.PNG

Thanks & Regards

Sarah

5 Replies

Re: Is it possible to access a meassure or dimension value from the function?

If you need to use the ratio in more places you can put the expression in a variable. For now you will have to create the variable in the load script


SET vSuccessRatio = count({<tcdatasuccess = {'OK'}>}tcdatasuccess)/count({<tcdatasuccess =

{'OK','NOK'}>}tcdatasuccess);


In expressions you can then (re)use the variable: if( $(vSuccessRatio) < 0.5, ..., ...)


talk is cheap, supply exceeds demand
Not applicable

Re: Is it possible to access a meassure or dimension value from the function?

Hey Gysbert

It sound's very interesting. I tried as you suggested. But the result is only a -

formula.PNG

I also used the line below, but the - still remains.

vSuccessRatio: count(tcdatasuccess)

What is wrong with my code?

Re: Is it possible to access a meassure or dimension value from the function?

In the script you use the SET or LET keyword to create variables:

SET vSuccessRatio = count({<tcdatasuccess = {'OK'}>}tcdatasuccess)/count({<tcdatasuccess =

{'OK','NOK'}>}tcdatasuccess);

After adding the code to create the variable you will have to reload the document to actually create the variable.


talk is cheap, supply exceeds demand
Not applicable

Re: Is it possible to access a meassure or dimension value from the function?

Ah ok, I tought it could be possible to declare a variable in the formula editor.

With declaring a variable in the script editor it was working.

Thanks for clarificaton.

Employee
Employee

Re: Is it possible to access a meassure or dimension value from the function?

Hi Sarah,

Variable support via the UI is not yet implemented but is something in consideration for a future release.

Mike T

Qlik