Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
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
Gysbert_Wassenaar

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
Author

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?

Gysbert_Wassenaar

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
Author

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.

Michael_Tarallo
Employee
Employee

Hi Sarah,

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

Mike T

Qlik

Regards,
Mike Tarallo
Qlik