Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

AllowMacroFunctionsInExpressions AND ActiveDocument.Evaluate()

Hi!

ActiveDocument.Evaluate() works fine at MSGBOX, for example:

msgbox ActiveDocument.Evaluate("subfield('a,b,c', ',', 2)")

But dnt work at interface TextObject with AllowMacroFunctionsInExpressions=1

Interface object must contain "=fEvaluate('subfield('a,b,c', ',', 2)')" without double quotes.

Work example (use Eval() VBS function):

FUNCTION fEvaluate(N)

  fEvaluate = Eval(N)

END FUNCTION

Dnt work sample:

FUNCTION fEvaluate(N)

  fEvaluate = ActiveDocument.Evaluate(N)

END FUNCTION

Can someone help me make it work?

19 Replies
petter
Partner - Champion III
Partner - Champion III

A first note:

the Eval() function of VBS is something completely different from the Evaluate member of the QlikView Automation API.

Why do you want to evaluate something that you can do directly in a textbox expression anyway? Is this just a "toy" example that you pose - not what you really need to do with Evaluate?

Not applicable
Author

Yes its a toy example.

My case need to calculate text string expression contained in a field linked to title field.

For real example i need to build chart of KPIs, with dimention and expressions like this picture:

img-2015-12-23-18-24-51.png

Now i beat it using VALUELIST('BUDGET','ACTUAL','VARIANCE') as dimention and expressions like

IF(

  VALUELIST('BUDGET','ACTUAL','VARIANCE')='BUDGET'

  ,1

,IF(VALUELIST('BUDGET','ACTUAL','VARIANCE')='ACTUAL'

  ,2

,IF(VALUELIST('BUDGET','ACTUAL','VARIANCE')='VARIANCE'

  ,3

)))

But its simple case and i need to add more dimentions and expressions.

When i put first column as dimention and convert expression as other columns, ill happy. 😃

Using Evaluate() this case must work with script:

LOAD * INLINE [

Title, Budget, Actial, Variance

Total Flights, sum(A), sum(B), sum(A)-sum(B)

]

And chart with dimention Title and expressions like =fEvaluate([Budget]) for Budget column.

--kind refards.

marcus_sommer

What should be the use of macro-functions in your case?

- Marcus

Not applicable
Author

previous post corrected

marcus_sommer

You could use The Magic of Dollar Expansions for this, like: $(=Budget)

- Marcus

Not applicable
Author

Marcus, $() calculate once per chart, am tryin' it already. May be other solution?

marcus_sommer

What didn't work? I think it would be helpful you post more details. In general it's possible to create a table-chart without a real dimension and assign certain expression to the virtual dimension without macro-functions (are the absolute worst case) and $-sign expansion (which could be very often applied).

- Marcus

petter
Partner - Champion III
Partner - Champion III

Could something like this work for you?

2015-12-23 #1.PNG

I have attached the QVW too for you to have a look at...

Not applicable
Author

petter-s thanks, very interesing example.

But it has same logics like valuelist() case.

The target of my question is understand of "why Evaluation() function which must return text, cant"?

And globally this solution can extend current functionality of reportiong.

Marcus, now, using of $() is closest solution, but it cant get array of arguments linked to dimention, it calculates once per chart and incert single (not dimention dependent) string in $(=) or numeric in $(#=) value.