Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Highlighted
graham-crooks
New Contributor III

Can a function defined in Module be called as an expression in a table chart?

Hi All

Here's my latest puzzle. I'm seeking to present KPI data in QV. In an existing Microsoft Access database query, a result is calculated (say, Nominator / Denominator) and a function call determines whether it meets a target - the result of the function call comes back as "P"ass or "F"ail.  For simplicity, I'll state the function as getPassFail(Result, Target1, Target2). In QV, I have the calculated result (Result) and the target values (Target1,Target2). It seems I can replicate the function in the code Module as vbscript. I'm uncertain however as to how or whether I can call this function in an expression in my table chart (where I want to show the outcome). As soon as I type getPassFail(Result, Target1, Target2) in the expression editor, I get a bad expression message in the expression editor and simply '-' in the chart. Please can someone advise, or point me towards a useful resource that explains how to get this to work please? Or if I'm making mis-assumptions or should be taking a different approach, please put me straight on the subject. Outdone by MS Access - surely not....

Cheers

Graham

Addendum: An example file might help illustrate perhaps?

4 Replies
mov
Esteemed Contributor III

Can a function defined in Module be called as an expression in a table chart?

Graham,

Your assumption is incorrect, sorry.  You cannot use custom module functions in the front-end objects, you can use them only in script.
You can use macros on front end.  Macro should be triggered by some event - selection, field change, button, etc.
I do not download attachemnts, so can't see what exactly the problem is.  I'm sure there are ways to address this.  Looks like all you need is the conditional expression (if).

Regards,
Michael

graham-crooks
New Contributor III

Can a function defined in Module be called as an expression in a table chart?

Michael.

Thank you for this - at least I know now that I cannot have what I wanted here. As defining and using functions is a classic means of reducing code repetition and maintenance, it seems a shame this approach cannot be used in qlikview. The actual 'if' statement in this case covers a wide range of possibilities, and therefore consumes quite a few lines of code - which now have to be replicated and maintained in each object individually - hardly classic efficiency. Hey ho.

mov
Esteemed Contributor III

Can a function defined in Module be called as an expression in a table chart?

Graham,

You can utilize variables - define function in a variable, and use this variable as expression.  It works fine if the expression is exactly the same in multiple charts.
If expression is using inputs as paramaters, I think it still can be done using variables, although not that straightforward.  I'll give it a try when have time...

pljsoftware
Contributor III

Re: Can a function defined in Module be called as an expression in a table chart?

Hi,

yes is possible.

Look this https://community.qlik.com/docs/DOC-4651#comment-48395

and look the attach.

Best regards

Luca Jonathan Panetta