Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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?
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?
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:
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.
What should be the use of macro-functions in your case?
- Marcus
previous post corrected
You could use The Magic of Dollar Expansions for this, like: $(=Budget)
- Marcus
Marcus, $() calculate once per chart, am tryin' it already. May be other solution?
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
Could something like this work for you?
I have attached the QVW too for you to have a look at...
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.